mongoid-filterable 0.3.1 → 0.4.0
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 +5 -5
- data/.travis.yml +20 -0
- data/Gemfile +2 -0
- data/README.md +2 -2
- data/Rakefile +6 -1
- data/gemfiles/mongoid-6.0.gemfile +7 -0
- data/gemfiles/mongoid-7.0.gemfile +7 -0
- data/lib/mongoid-filterable/filterable.rb +1 -1
- data/lib/mongoid-filterable/version.rb +1 -1
- data/spec/filterable_spec.rb +10 -1
- metadata +6 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: e6168dc7e61425d57051a385ad08c7061e0690b68895a1a06791dbbe5ba6e3f0
|
4
|
+
data.tar.gz: 51b6a89e1f0454f62d4b502d920b0e7b76d03d5f61d2fbb7ea613b9d09772968
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9e1d37765dd64fa1c3322045a5632a757ad217e7c243524696f026d70db8cc988d4f9825fd54e146dfba6b14d7534c80204e4c82abe27fe4a129f7edd17d94fe
|
7
|
+
data.tar.gz: a6167fb4ecbd8b2e6342ba87ab703388a231b7dff891e26cbef84f2a22bc6c7e9b78683838b2b3e7987c8264f7014c409fbda03dcee4732668e69570a5b61662
|
data/.travis.yml
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
sudo: false
|
2
|
+
language: ruby
|
3
|
+
rvm:
|
4
|
+
- 2.5.1
|
5
|
+
before_install: gem install bundler -v 1.16.1
|
6
|
+
|
7
|
+
gemfile:
|
8
|
+
- Gemfile
|
9
|
+
- gemfiles/mongoid-6.0.gemfile
|
10
|
+
- gemfiles/mongoid-7.0.gemfile
|
11
|
+
|
12
|
+
services:
|
13
|
+
- mongodb
|
14
|
+
|
15
|
+
addons:
|
16
|
+
apt:
|
17
|
+
sources:
|
18
|
+
- mongodb-3.4-precise
|
19
|
+
packages:
|
20
|
+
- mongodb-org-server
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -18,7 +18,7 @@ Or install it yourself as:
|
|
18
18
|
|
19
19
|
## Compatibility
|
20
20
|
|
21
|
-
Mongoid Filterable supports Mongoid versions 3, 4, 5, and now
|
21
|
+
Mongoid Filterable supports Mongoid versions 3, 4, 5, 6 and now 7.
|
22
22
|
|
23
23
|
## Usage
|
24
24
|
|
@@ -34,7 +34,7 @@ class City
|
|
34
34
|
|
35
35
|
filter_by(:name)
|
36
36
|
filter_by(:people, ->(value) { where(:people.gt => value) })
|
37
|
-
filter_by(:people_range, (lambda do |range_start, range_end|
|
37
|
+
filter_by(:people_range, (lambda do |range_start, range_end|
|
38
38
|
where(:people.lte => range_end,
|
39
39
|
:people.gte => range_start)
|
40
40
|
end))
|
data/Rakefile
CHANGED
@@ -14,7 +14,7 @@ module Mongoid
|
|
14
14
|
criteria = unscoped
|
15
15
|
|
16
16
|
filtering_params.each do |key, value|
|
17
|
-
if value.
|
17
|
+
if !value.nil? && respond_to?("filter_with_#{key}")
|
18
18
|
if value.is_a?(Array) && scopes["filter_with_#{key}".to_sym][:scope].arity > 1
|
19
19
|
selectors.push criteria.public_send("filter_with_#{key}", *value).selector
|
20
20
|
else
|
data/spec/filterable_spec.rb
CHANGED
@@ -13,6 +13,7 @@ describe Mongoid::Filterable do
|
|
13
13
|
field :people, type: Integer
|
14
14
|
field :country_normalized
|
15
15
|
|
16
|
+
filter_by(:active)
|
16
17
|
filter_by(:name)
|
17
18
|
filter_by(:code)
|
18
19
|
filter_by(:people, ->(value) { where(:people.gt => value) })
|
@@ -25,7 +26,7 @@ describe Mongoid::Filterable do
|
|
25
26
|
end
|
26
27
|
|
27
28
|
before do
|
28
|
-
City.destroy_all
|
29
|
+
City.unscoped.destroy_all
|
29
30
|
end
|
30
31
|
|
31
32
|
context 'when use default operator' do
|
@@ -123,6 +124,14 @@ describe Mongoid::Filterable do
|
|
123
124
|
end
|
124
125
|
end
|
125
126
|
|
127
|
+
context 'when value is a Boolean' do
|
128
|
+
it 'should filter using a query' do
|
129
|
+
City.create(name: 'city1')
|
130
|
+
City.create(name: 'city2', active: false)
|
131
|
+
expect(City.unscoped.filter(active: false).count).to eq(1)
|
132
|
+
end
|
133
|
+
end
|
134
|
+
|
126
135
|
context 'when filter is applied on a scope' do
|
127
136
|
it 'previous scope is maintained' do
|
128
137
|
City.create(name: '2', people: 100)
|
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
|
+
version: 0.4.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: 2018-05-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -74,10 +74,13 @@ extensions: []
|
|
74
74
|
extra_rdoc_files: []
|
75
75
|
files:
|
76
76
|
- ".gitignore"
|
77
|
+
- ".travis.yml"
|
77
78
|
- Gemfile
|
78
79
|
- LICENSE.txt
|
79
80
|
- README.md
|
80
81
|
- Rakefile
|
82
|
+
- gemfiles/mongoid-6.0.gemfile
|
83
|
+
- gemfiles/mongoid-7.0.gemfile
|
81
84
|
- lib/mongoid-filterable.rb
|
82
85
|
- lib/mongoid-filterable/filterable.rb
|
83
86
|
- lib/mongoid-filterable/version.rb
|
@@ -105,7 +108,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
105
108
|
version: '0'
|
106
109
|
requirements: []
|
107
110
|
rubyforge_project:
|
108
|
-
rubygems_version: 2.
|
111
|
+
rubygems_version: 2.7.6
|
109
112
|
signing_key:
|
110
113
|
specification_version: 4
|
111
114
|
summary: Easy way to add scopes to your models.
|