mongoid-filterable 0.4.0 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -0
- data/lib/mongoid-filterable/filterable.rb +2 -1
- data/lib/mongoid-filterable/version.rb +1 -1
- data/mongoid-filterable.gemspec +11 -11
- data/spec/filterable_spec.rb +16 -0
- metadata +12 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 71010c85b650681652bd079d24a156341bee7f1f9594d03fe3fd6d1636ab9083
|
4
|
+
data.tar.gz: 91a7a5441612055ea19400f403d94d934117b39a7d71a110684d2f9d502f1bc8
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0fe5207b06afd57c1681131cfb6acd99a87b8acdf66ffb97812f6f81e00dc34a5af512fdb6fc8c1246966ebe5d6ea3a3cafe8180b5fe78a64e6aba21dcbc94ee
|
7
|
+
data.tar.gz: cbb78b9092a458ca27e75b4ffbc44a29ca0b38fea927a6c6f53c8ce2c04255aa2029efe129535bea351670440f0d3f7e9c83db6904e9fa98ce809c77df9cebc5
|
data/README.md
CHANGED
@@ -14,7 +14,8 @@ module Mongoid
|
|
14
14
|
criteria = unscoped
|
15
15
|
|
16
16
|
filtering_params.each do |key, value|
|
17
|
-
|
17
|
+
# false is permitted in order to work properly with boolean fields
|
18
|
+
if (value.present? || value == false) && respond_to?("filter_with_#{key}")
|
18
19
|
if value.is_a?(Array) && scopes["filter_with_#{key}".to_sym][:scope].arity > 1
|
19
20
|
selectors.push criteria.public_send("filter_with_#{key}", *value).selector
|
20
21
|
else
|
data/mongoid-filterable.gemspec
CHANGED
@@ -4,22 +4,22 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'mongoid-filterable/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
7
|
+
spec.name = 'mongoid-filterable'
|
8
8
|
spec.version = Mongoid::Filterable::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
11
|
-
spec.summary =
|
12
|
-
spec.description =
|
13
|
-
spec.homepage =
|
14
|
-
spec.license =
|
9
|
+
spec.authors = ['Rafael Jurado']
|
10
|
+
spec.email = ['rjurado@nosolosoftware.biz']
|
11
|
+
spec.summary = 'Easy way to add scopes to your models.'
|
12
|
+
spec.description = 'Easy way to add scopes to your models.'
|
13
|
+
spec.homepage = ''
|
14
|
+
spec.license = 'MIT'
|
15
15
|
|
16
16
|
spec.files = `git ls-files -z`.split("\x0")
|
17
17
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
|
-
spec.require_paths = [
|
19
|
+
spec.require_paths = ['lib']
|
20
20
|
|
21
|
-
spec.add_development_dependency
|
21
|
+
spec.add_development_dependency 'bundler', '~> 1.5'
|
22
22
|
spec.add_development_dependency 'rspec'
|
23
|
-
spec.add_dependency '
|
24
|
-
spec.add_dependency
|
23
|
+
spec.add_dependency 'i18n'
|
24
|
+
spec.add_dependency 'mongoid', ['>= 3.0', '< 8.0']
|
25
25
|
end
|
data/spec/filterable_spec.rb
CHANGED
@@ -124,6 +124,22 @@ describe Mongoid::Filterable do
|
|
124
124
|
end
|
125
125
|
end
|
126
126
|
|
127
|
+
context 'when value is nil' do
|
128
|
+
it 'should ignore filter' do
|
129
|
+
City.create(people: 100)
|
130
|
+
City.create(people: 500)
|
131
|
+
expect(City.filter(people: nil).count).to eq(2)
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
135
|
+
context 'when value is empty string' do
|
136
|
+
it 'should ignore filter' do
|
137
|
+
City.create(people: 100)
|
138
|
+
City.create(people: 500)
|
139
|
+
expect(City.filter(people: '').count).to eq(2)
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
127
143
|
context 'when value is a Boolean' do
|
128
144
|
it 'should filter using a query' do
|
129
145
|
City.create(name: 'city1')
|
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.4.
|
4
|
+
version: 0.4.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Rafael Jurado
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-05-
|
11
|
+
date: 2018-05-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -39,7 +39,7 @@ dependencies:
|
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
|
-
name:
|
42
|
+
name: i18n
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
45
|
- - ">="
|
@@ -53,19 +53,25 @@ dependencies:
|
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|
56
|
-
name:
|
56
|
+
name: mongoid
|
57
57
|
requirement: !ruby/object:Gem::Requirement
|
58
58
|
requirements:
|
59
59
|
- - ">="
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: '0'
|
61
|
+
version: '3.0'
|
62
|
+
- - "<"
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '8.0'
|
62
65
|
type: :runtime
|
63
66
|
prerelease: false
|
64
67
|
version_requirements: !ruby/object:Gem::Requirement
|
65
68
|
requirements:
|
66
69
|
- - ">="
|
67
70
|
- !ruby/object:Gem::Version
|
68
|
-
version: '0'
|
71
|
+
version: '3.0'
|
72
|
+
- - "<"
|
73
|
+
- !ruby/object:Gem::Version
|
74
|
+
version: '8.0'
|
69
75
|
description: Easy way to add scopes to your models.
|
70
76
|
email:
|
71
77
|
- rjurado@nosolosoftware.biz
|