Skip to content

Commit

Permalink
Rename search to dig
Browse files Browse the repository at this point in the history
This is inline with the taxonomy of superglue and changes made in props_template.

thoughtbot/props_template@92de606
  • Loading branch information
jho406 committed Dec 31, 2024
1 parent be6b571 commit 2cc602b
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions docs/cross-cutting-concerns.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ If you have state that is shared between pages, simply put it in your layout.
For example. In the generated `application.json.props`

```ruby
path = request.format.json? ? param_to_search_path(params[:props_at]) : nil
path = request.format.json? ? param_to_dig_path(params[:props_at]) : nil

json.data(search: path) do
json.data(dig: path) do
json.temperature "HOT HOT HOT"
yield json
end
Expand Down
14 changes: 7 additions & 7 deletions docs/digging.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ The `props_at` param is a keypath to the content in your PropsTemplate. As a sim
example, imagine this page with no layouts:

```ruby
path = param_to_search_path(params[:props_at])
json.data(search: path) do
path = param_to_dig_path(params[:props_at])
json.data(dig: path) do
json.header do
json.search do
# Results is a leaf node
Expand Down Expand Up @@ -60,8 +60,8 @@ content in async fashion.
There are two ways to query collections. Looking at the following example:

```ruby
path = param_to_search_path(params[:props_at])
json.data(search: path) do
path = param_to_dig_path(params[:props_at])
json.data(dig: path) do
json.posts do
json.array! @posts do |post|
json.details do
Expand Down Expand Up @@ -103,8 +103,8 @@ To enable this, you are required to implement `member_by(attribute, value)` on
the passed collection AND use the option `:key` in `json.array!`. For example:

```ruby
path = param_to_search_path(params[:props_at])
json.data(search: params[:props_at]) do
path = param_to_dig_path(params[:props_at])
json.data(dig: params[:props_at]) do
json.posts do
json.array! @posts, key: :some_id do |post|
json.details do
Expand All @@ -127,7 +127,7 @@ remote('/dashboard?props_at=data.posts.some_id=1.details')
```

```ruby
json.data(search: params[:props_at]) do
json.data(dig: params[:props_at]) do
json.posts(partial: 'list_of_posts')do
end
end
Expand Down
2 changes: 1 addition & 1 deletion docs/tutorial.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ the tabs to see what happens when `@path` changes for the example below.


```ruby
json.data(search: @path) do
json.data(dig: @path) do
json.body do
json.chart do
sleep 10
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
path = request.format.json? ? param_to_search_path(params[:props_at]) : nil
path = request.format.json? ? param_to_dig_path(params[:props_at]) : nil

json.data(search: path) do
json.data(dig: path) do
yield json
end

Expand Down
2 changes: 1 addition & 1 deletion superglue_rails/lib/superglue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ module Controller

def self.included(base)
if base.respond_to?(:helper_method)
base.helper_method :param_to_search_path
base.helper_method :param_to_dig_path
end
end
end
Expand Down
2 changes: 1 addition & 1 deletion superglue_rails/lib/superglue/helpers.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def redirect_back_with_props_at(opts)
end
end

def param_to_search_path(param)
def param_to_dig_path(param)
if param
param
.gsub(/[^\da-zA-Z_=.]+/, "")
Expand Down
4 changes: 2 additions & 2 deletions superglue_rails/test/helpers_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ class HelpersTest < ActiveSupport::TestCase
test "clean_props_at returns nil if qry is nil" do
qry = nil

assert_nil param_to_search_path(qry)
assert_nil param_to_dig_path(qry)
end

test "clean_props_at returns a refined qry" do
qry = "foo...bar/?)()-"

assert_equal param_to_search_path(qry), ["foo", "bar"]
assert_equal param_to_dig_path(qry), ["foo", "bar"]
end
end

0 comments on commit 2cc602b

Please sign in to comment.