filtering 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cff302567fe65d0891e336fbd24a4abc2a7dc72f
4
- data.tar.gz: 4990e53c9f347af71eb5cecfb7f7de6d02de4d5c
3
+ metadata.gz: 2d10e915ebf65faf4e5bde4d5757bf482638c2c6
4
+ data.tar.gz: c1aae098a832689f11562c4a04a760cc67ad702f
5
5
  SHA512:
6
- metadata.gz: 6fb220d98c16d465d9f60628d2f1029f54c452803667fffb297a2cd377c26812d4b4522c1dd461bf9676e3cc524db00d66ebb6c440e48382a3517454e16d9b07
7
- data.tar.gz: ccaee684fee547d705a6d221acbbaa3bda3c102fa524c57dfddba0bc8ba6e67e43e8edda0ef350e859c1a1a252c8a63690f49057b29a8f70ba6db06b674047b2
6
+ metadata.gz: 747eaed5311cc56b010dca7b3b40b9bdd9b84deea49df1d07a5e132730d05638d6efaf67aca14500e6d680185b15e58426aca607394e5647bf20cc8b372ddf92
7
+ data.tar.gz: 5ad728b74ae091db15c3432cb5168e01d8adc1b71b9594eec68db9ac707e3e90639f852eb46d81f5e57ff836e0d6c3ab22e887c9533b642f355d72062a915a46
data/Gemfile.lock ADDED
@@ -0,0 +1,35 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ filtering (0.1.0)
5
+
6
+ GEM
7
+ remote: https://rubygems.org/
8
+ specs:
9
+ diff-lcs (1.3)
10
+ rake (10.5.0)
11
+ rspec (3.7.0)
12
+ rspec-core (~> 3.7.0)
13
+ rspec-expectations (~> 3.7.0)
14
+ rspec-mocks (~> 3.7.0)
15
+ rspec-core (3.7.1)
16
+ rspec-support (~> 3.7.0)
17
+ rspec-expectations (3.7.0)
18
+ diff-lcs (>= 1.2.0, < 2.0)
19
+ rspec-support (~> 3.7.0)
20
+ rspec-mocks (3.7.0)
21
+ diff-lcs (>= 1.2.0, < 2.0)
22
+ rspec-support (~> 3.7.0)
23
+ rspec-support (3.7.1)
24
+
25
+ PLATFORMS
26
+ ruby
27
+
28
+ DEPENDENCIES
29
+ bundler (~> 1.16)
30
+ filtering!
31
+ rake (~> 10.0)
32
+ rspec (~> 3.0)
33
+
34
+ BUNDLED WITH
35
+ 1.16.1
data/README.md CHANGED
@@ -24,7 +24,7 @@ All you need to do is inherit custom filter service from `Filtering::Base` and d
24
24
  ### Example filter service
25
25
 
26
26
  ```
27
- class Filters::OffersFilter < Filtering::Base
27
+ class Filters::UsersFilter < Filtering::Base
28
28
  def initialize(params, page)
29
29
  super(params, page)
30
30
  end
@@ -37,7 +37,7 @@ class Filters::OffersFilter < Filtering::Base
37
37
  User.all
38
38
  end
39
39
 
40
- def simple_acessible_params
40
+ def plain_acessible_params
41
41
  %i[city age]
42
42
  end
43
43
 
@@ -53,23 +53,23 @@ class Filters::OffersFilter < Filtering::Base
53
53
  end
54
54
 
55
55
  ```
56
- There are required private methods:
56
+ There are private methods:
57
57
 
58
58
  `relation` is an ActiveRecord initial relation which must be filtered
59
59
 
60
- `plain_acessible_params` array of params for auto-filtering by `where`, so if you have `%i[city age]` will be called `User.where(city: city).where(age: age)`
60
+ `plain_acessible_params` array of params for an auto-filtering by `where`, so if you have `%i[city age]` will be called `User.where(city: city).where(age: age)`
61
61
 
62
- `complex_acessible_params` array of params for filters with custom logic. If you have some params in that method you have to create methods for those custom filters by format: `filter_by_{param}`
62
+ `complex_acessible_params` array of params for filters with custom logic. If you have some params in that method you have to create methods for those custom filters with format: `filter_by_{param}`
63
63
 
64
64
  ### Calling
65
- Feel free to call new service wherever you want. For example in controller:
65
+ Controller usage example:
66
66
 
67
67
  ```
68
68
  def index
69
- render json: Filters::OffersFilter.new(params, params[:page]).call
69
+ render json: Filters::UsersFilter.new(params, page: params[:page]).call
70
70
  end
71
71
  ```
72
- If you don't use caminari just delete page from initializer
72
+ If you don't use Kaminari just delete page from initializer
73
73
 
74
74
  ## License
75
75
 
@@ -1,8 +1,8 @@
1
1
  class Filtering::Base
2
- def initialize(params, page = nil)
2
+ def initialize(params, args = {})
3
3
  @plain_params = params.permit(plain_acessible_params)
4
4
  @complex_params = params.permit(complex_acessible_params)
5
- @page = page
5
+ @page = args[:page]
6
6
  @results = relation
7
7
  end
8
8
 
@@ -1,3 +1,3 @@
1
1
  module Filtering
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: filtering
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Vitaliy
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2018-05-10 00:00:00.000000000 Z
11
+ date: 2018-05-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -64,6 +64,7 @@ files:
64
64
  - ".travis.yml"
65
65
  - CODE_OF_CONDUCT.md
66
66
  - Gemfile
67
+ - Gemfile.lock
67
68
  - LICENSE.txt
68
69
  - README.md
69
70
  - Rakefile