mongoid-filterable 0.0.3 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +1 -0
- data/lib/mongoid-filterable/filterable.rb +3 -1
- data/lib/mongoid-filterable/version.rb +1 -1
- data/mongoid-filterable.gemspec +2 -3
- data/spec/filterable_spec.rb +8 -0
- data/spec/spec_helper.rb +4 -1
- data/spec/support/mongoid.yml +3 -3
- metadata +7 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4b18210c949bcbfb7ad280790bd2e83f42d27736
|
4
|
+
data.tar.gz: f8ac9f1c9f672ff292175328977e73170214fced
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a331c668aa00285c52f8d62ef46e8893c303ebe2f14930790bf56f96878150dac561d51a2458f0dba320c213c973e3e249f27ceddc5751989ae9e4c4129d96b3
|
7
|
+
data.tar.gz: a2615a0671fc4c754620659f6a65e4e5f0242863ac564d08d44a4b5e873ccf9160352c4ab9b207f66d29324ecd6cd1793ba201ac5da174fc848947fb7a72fe95
|
data/Gemfile
CHANGED
@@ -12,7 +12,9 @@ module Mongoid
|
|
12
12
|
selectors = []
|
13
13
|
|
14
14
|
filtering_params.each do |key, value|
|
15
|
-
|
15
|
+
if value.present? && self.respond_to?("filter_with_#{key}")
|
16
|
+
selectors.push self.public_send("filter_with_#{key}", value).selector
|
17
|
+
end
|
16
18
|
end
|
17
19
|
|
18
20
|
results.selector = {operator => selectors} if selectors.size > 0
|
data/mongoid-filterable.gemspec
CHANGED
@@ -19,8 +19,7 @@ Gem::Specification.new do |spec|
|
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
21
|
spec.add_development_dependency "bundler", "~> 1.5"
|
22
|
-
spec.add_development_dependency "rake"
|
23
|
-
spec.add_development_dependency "i18n"
|
24
22
|
spec.add_development_dependency 'rspec'
|
25
|
-
spec.
|
23
|
+
spec.add_dependency 'mongoid'
|
24
|
+
spec.add_dependency "i18n"
|
26
25
|
end
|
data/spec/filterable_spec.rb
CHANGED
@@ -66,4 +66,12 @@ describe Mongoid::Filterable do
|
|
66
66
|
expect(City.filter({name: 'city1', people: '2000'}, '$or').count).to eq(1)
|
67
67
|
end
|
68
68
|
end
|
69
|
+
|
70
|
+
context 'when use invalid filter' do
|
71
|
+
it 'should ignore filter' do
|
72
|
+
City.create(name: 'city1')
|
73
|
+
City.create(name: 'city2')
|
74
|
+
expect(City.filter({invalid: 'val'}).count).to eq(2)
|
75
|
+
end
|
76
|
+
end
|
69
77
|
end
|
data/spec/spec_helper.rb
CHANGED
data/spec/support/mongoid.yml
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongoid-filterable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rafael Jurado
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-05-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -25,21 +25,7 @@ dependencies:
|
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.5'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
|
-
name:
|
29
|
-
requirement: !ruby/object:Gem::Requirement
|
30
|
-
requirements:
|
31
|
-
- - ">="
|
32
|
-
- !ruby/object:Gem::Version
|
33
|
-
version: '0'
|
34
|
-
type: :development
|
35
|
-
prerelease: false
|
36
|
-
version_requirements: !ruby/object:Gem::Requirement
|
37
|
-
requirements:
|
38
|
-
- - ">="
|
39
|
-
- !ruby/object:Gem::Version
|
40
|
-
version: '0'
|
41
|
-
- !ruby/object:Gem::Dependency
|
42
|
-
name: i18n
|
28
|
+
name: rspec
|
43
29
|
requirement: !ruby/object:Gem::Requirement
|
44
30
|
requirements:
|
45
31
|
- - ">="
|
@@ -53,13 +39,13 @@ dependencies:
|
|
53
39
|
- !ruby/object:Gem::Version
|
54
40
|
version: '0'
|
55
41
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
42
|
+
name: mongoid
|
57
43
|
requirement: !ruby/object:Gem::Requirement
|
58
44
|
requirements:
|
59
45
|
- - ">="
|
60
46
|
- !ruby/object:Gem::Version
|
61
47
|
version: '0'
|
62
|
-
type: :
|
48
|
+
type: :runtime
|
63
49
|
prerelease: false
|
64
50
|
version_requirements: !ruby/object:Gem::Requirement
|
65
51
|
requirements:
|
@@ -67,13 +53,13 @@ dependencies:
|
|
67
53
|
- !ruby/object:Gem::Version
|
68
54
|
version: '0'
|
69
55
|
- !ruby/object:Gem::Dependency
|
70
|
-
name:
|
56
|
+
name: i18n
|
71
57
|
requirement: !ruby/object:Gem::Requirement
|
72
58
|
requirements:
|
73
59
|
- - ">="
|
74
60
|
- !ruby/object:Gem::Version
|
75
61
|
version: '0'
|
76
|
-
type: :
|
62
|
+
type: :runtime
|
77
63
|
prerelease: false
|
78
64
|
version_requirements: !ruby/object:Gem::Requirement
|
79
65
|
requirements:
|