cast_about_for 0.1.1 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 767ed28a1c4419971645523dc4f7c806995eea5b
4
- data.tar.gz: 65fe5b3fbc32d318f17a987a75b076e9412c2b72
3
+ metadata.gz: f89b80544593269d2556df48a28845c7b9afb875
4
+ data.tar.gz: f32a8afe8c775646c101a17976ff144d43d43076
5
5
  SHA512:
6
- metadata.gz: e8f7def0a88a6d6e7f368faa94eaa80400cc735012c60a37ade4c9c2e1cb4f094754d23a1ee51b51cdab3998b5b49870a374801f66f8f689bf2ad934f6e81431
7
- data.tar.gz: a4953ee1aaf64abb56975d115871dc2e21d2ad23f8173137ecd0dcf63d23688de4287aa83c1c88cfc06b9d9f1689c3ae2ea1ecaa15d88d52101e33ad017f291b
6
+ metadata.gz: c1ee3ad830d4fa24b31b4f45c000561120c72059b0945741909aa3e980ae952005f593eadea3ee95d2ce734387d88e63e8b6fff9b5cb9811302b10d6e84d3441
7
+ data.tar.gz: 071d92105a788ec87ba1a930dd42c88962637a2feea7ad956e2b018ac02569288687d94abb2b4e9236519da367ab877d756c87fdfa5782ae35a7059c29f652f9
data/README.md CHANGED
@@ -242,11 +242,14 @@ If you are using `JSON API`, you can set in the `#cast_about_for`:
242
242
  ```
243
243
 
244
244
  ### Custom Query by Block
245
+ If want to find products where belong to some people, you can do it like:
245
246
 
246
247
  ```ruby
247
- Product.cast_about_for(params, jsonapi: true) do |product|
248
- product.where(name: 'hello')
249
- next product
248
+ params = { user_name: 'hello', age: 20 }
249
+
250
+ Product.cast_about_for(params, jsonapi: true) do |products, cast_params|
251
+ products = products.joins(:user).where("users.name Like ?", "%#{cast_params[:user_name]}%") if cast_params[:user_name].present?
252
+ products = products.joins(:user).where("users.age = ?", cast_params[:age]) if cast_params[:age].present?
250
253
  end
251
254
  ```
252
255
 
@@ -13,7 +13,7 @@ module CastAboutFor
13
13
  seach_model = send("cast_about_for_by_#{key}", value, params, seach_model)
14
14
  end
15
15
 
16
- seach_model = yield(seach_model) if block_given?
16
+ seach_model = yield(seach_model, params) if block_given?
17
17
 
18
18
  return seach_model
19
19
  end
@@ -1,3 +1,3 @@
1
1
  module CastAboutFor
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cast_about_for
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - JeskTop