filterism 2.0.0 → 2.0.1
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 +4 -4
- data/README.md +3 -1
- data/lib/filterism/parsers/params_parser.rb +1 -1
- data/lib/filterism/version.rb +1 -1
- data/spec/parsers/params_parser_spec.rb +9 -9
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 702e375614a34c3ccc1f0b2225d9e3d34f89fe4a
|
4
|
+
data.tar.gz: f700e3efb545b7b647c9ba6eeefed66a3c194ef4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 31e0392b503b2a212623c35d08e0224acf81acf046e8a88d73dce9cee484362cdc969700565f944bb8383f4c4fd37ec002face53d53f4c6dede2e19d7014d779
|
7
|
+
data.tar.gz: 9d6281f69aaddbb70f3084c674cc34990ae0e2b0223426d7cbc7d5fe3cd26db69755299eeeee02a38899fc967ff2ee50c80ecc7031fbfe39714e4c5f4b6d12c9
|
data/README.md
CHANGED
@@ -69,7 +69,9 @@ The examples above are equivalent. If you have a long list of fields, you can u
|
|
69
69
|
This gem adds the ".filter" class method to any active record class. You can pass in any hash, it doesn't have to operate from params. It will only look at keys that have the "\_is\_" syntax.
|
70
70
|
|
71
71
|
``` ruby
|
72
|
-
|
72
|
+
parser = Filterism::ParamsParser.new
|
73
|
+
parsed_params = parser.parse(params)
|
74
|
+
users = User.filter(parsed_params).all
|
73
75
|
```
|
74
76
|
|
75
77
|
## Comparators
|
data/lib/filterism/version.rb
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe Filterism::
|
3
|
+
describe Filterism::ParamsParser do
|
4
4
|
before(:all) do
|
5
|
-
@
|
5
|
+
@params_parser = Filterism::ParamsParser.new
|
6
6
|
end
|
7
7
|
|
8
8
|
describe "#parse" do
|
9
9
|
it "has the parse method" do
|
10
|
-
expect(@
|
10
|
+
expect(@params_parser).to respond_to(:parse)
|
11
11
|
end
|
12
|
-
subject { -> (params) { return @
|
12
|
+
subject { -> (params) { return @params_parser.parse(params) }}
|
13
13
|
|
14
14
|
it "returns a hash" do
|
15
15
|
expect(subject.call({ name_is_equal_to: 'David' })).to be_an(Array)
|
@@ -30,22 +30,22 @@ describe Filterism::ConditionParser do
|
|
30
30
|
|
31
31
|
describe "#add_comparator" do
|
32
32
|
it "has the add_comparator method" do
|
33
|
-
expect(@
|
33
|
+
expect(@params_parser).to respond_to(:add_comparator).with(1).argument
|
34
34
|
end
|
35
35
|
|
36
36
|
it "adds the new comparator to the comparators Hash" do
|
37
|
-
expect(@
|
37
|
+
expect(@params_parser.add_comparator({"equals_to" => "="})).to include("equals_to" => "=")
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
41
|
describe "#delete_comparator" do
|
42
42
|
it "has the delete_comparator method" do
|
43
|
-
expect(@
|
43
|
+
expect(@params_parser).to respond_to(:delete_comparator).with(1).argument
|
44
44
|
end
|
45
45
|
|
46
46
|
it "deletes the comparator from the comparators Hash" do
|
47
|
-
@
|
48
|
-
expect(@
|
47
|
+
@params_parser.add_comparator({"equals_to" => "="})
|
48
|
+
expect(@params_parser.delete_comparator("equals_to")).not_to include("equals_to")
|
49
49
|
end
|
50
50
|
end
|
51
51
|
end
|