mongoid-filterable 0.2.0 → 0.2.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: 8569c578ae3ca2f65454cd555e1e782990d1683d
4
- data.tar.gz: 241bf4537c8bbd14941633fb90d3596a3c4e8cbd
3
+ metadata.gz: 1afed03de888d2a4efd38e70952e7dc9c5021969
4
+ data.tar.gz: 9e5ad498c4928cf82e67dade0b302388f8c590f7
5
5
  SHA512:
6
- metadata.gz: 850126a6da8200e6eb107f1540e9a027c7c1d44db15baeaf3c058500027c18ee0709e0c48474e55f9be43ff62d21792ecc211b55e6a242d571a10d1b46f3acdc
7
- data.tar.gz: c286fa0accc54edd85318462a1940e8cc17a40a3dcede73bf88226fa8713f1b7010843bfa93976359b6717f1f60969f53b0c1a932fca00438a2b0b4039e33e7d
6
+ metadata.gz: 4e995be00a0ae857130777daeab41b23dcf42cb3e8a5046a45536bed6c049546455780872f6ecf534c5acea7b30be2b0c92d193146e45d8a5c07ab0803b022d8
7
+ data.tar.gz: 7826c6b4649920c30685716627cc3368ac11b623d748cb394fb35cc3c73d247e6cb6bc99dce3d3ae4066ffcda449afa3f695c883d29203def0c8cd8eef6f4ace
data/README.md CHANGED
@@ -16,6 +16,10 @@ Or install it yourself as:
16
16
 
17
17
  $ gem install mongoid-filterable
18
18
 
19
+ ## Compatibility
20
+
21
+ Mongoid Filterable supports Mongoid versions 3, 4, 5, and now 6.
22
+
19
23
  ## Usage
20
24
 
21
25
  #### Model
@@ -11,7 +11,7 @@ module Mongoid
11
11
  return self unless filtering_params
12
12
  results = all
13
13
  selectors = []
14
- criteria = Mongoid::Criteria.new(self)
14
+ criteria = unscoped
15
15
 
16
16
  filtering_params.each do |key, value|
17
17
  if value.present? && respond_to?("filter_with_#{key}")
@@ -1,5 +1,5 @@
1
1
  module Mongoid
2
2
  module Filterable
3
- VERSION = '0.2.0'
3
+ VERSION = '0.2.1'
4
4
  end
5
5
  end
@@ -5,6 +5,9 @@ describe Mongoid::Filterable do
5
5
  include Mongoid::Document
6
6
  include Mongoid::Filterable
7
7
 
8
+ default_scope -> { where(active: true) }
9
+
10
+ field :active, type: Boolean, default: true
8
11
  field :name, type: String
9
12
  field :code, type: Symbol
10
13
  field :people, type: Integer
@@ -21,6 +24,12 @@ describe Mongoid::Filterable do
21
24
  end
22
25
 
23
26
  context 'when use default operator' do
27
+ it 'should create correct selector' do
28
+ expect(City.filter(code: :code1).selector).to eq(
29
+ {"active" => true, "$and" => [{"code" => :code1}]}
30
+ )
31
+ end
32
+
24
33
  it 'should filter by default filter' do
25
34
  City.create(code: :code1)
26
35
  City.create(code: :code2)
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.2.0
4
+ version: 0.2.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: 2017-03-22 00:00:00.000000000 Z
11
+ date: 2017-10-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -105,7 +105,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
105
105
  version: '0'
106
106
  requirements: []
107
107
  rubyforge_project:
108
- rubygems_version: 2.4.5.1
108
+ rubygems_version: 2.5.2
109
109
  signing_key:
110
110
  specification_version: 4
111
111
  summary: Easy way to add scopes to your models.
@@ -113,4 +113,3 @@ test_files:
113
113
  - spec/filterable_spec.rb
114
114
  - spec/spec_helper.rb
115
115
  - spec/support/mongoid.yml
116
- has_rdoc: