scoped-search 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/scoped_search.rb +2 -1
- metadata +3 -3
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.4.0
|
data/lib/scoped_search.rb
CHANGED
@@ -7,6 +7,7 @@ class ScopedSearch
|
|
7
7
|
extend ActiveModel::Naming
|
8
8
|
|
9
9
|
SINGLE_SCOPES_VALUES = %w(true 1)
|
10
|
+
EXCLUDED_SCOPES_VALUES = %w(false 0)
|
10
11
|
|
11
12
|
attr_reader :attributes, :model_class, :attributes_merged
|
12
13
|
|
@@ -30,7 +31,7 @@ class ScopedSearch
|
|
30
31
|
|
31
32
|
def build_relation
|
32
33
|
return model_class if attributes.empty?
|
33
|
-
attributes.reject { |k,v| v.blank? }.inject(model_class) do |s, k|
|
34
|
+
attributes.reject { |k,v| v.blank? || EXCLUDED_SCOPES_VALUES.include?(v.to_s) }.inject(model_class) do |s, k|
|
34
35
|
if model_class.scopes.keys.include?(k.first.to_sym)
|
35
36
|
k.size == 2 && SINGLE_SCOPES_VALUES.include?(k.last.to_s) ? s.send(k.first) : s.send(*k.flatten)
|
36
37
|
else
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: scoped-search
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 15
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
|
-
-
|
8
|
+
- 4
|
9
9
|
- 0
|
10
|
-
version: 0.
|
10
|
+
version: 0.4.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- slainer68
|