autoscope 0.0.2 → 0.0.3
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 +4 -4
- data/.rspec +1 -1
- data/lib/autoscope/active_record_methods.rb +11 -1
- data/lib/autoscope/version.rb +1 -1
- data/spec/lib/autoscope/active_record_methods_spec.rb +8 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9fa32721bcb23d20bb00efe3aab051c692a36cfb
|
4
|
+
data.tar.gz: f212e562d4430099db1a075e64c86aba0d65acb5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ef585e6d62fc8f3b21cf9ffc67e115ce31d648db10f5807d0f7b1b630593aff4864d497326aa5a30e233c2aa67979d7fd09b75ada246fb0eef5177f3f36ff7e5
|
7
|
+
data.tar.gz: 294b5c56475d6bb53b7059caafcf00a275374a480c5a0cccc92b4843f64524d6dd2b54f953c0e40468b576f1f4b29bdc3b32e19aef7e5d95556de2ade406d25f
|
data/.rspec
CHANGED
@@ -130,7 +130,7 @@ module Autoscope
|
|
130
130
|
scope.klass.dynamic_scopes.each_pair do |scope_name, arg_def|
|
131
131
|
|
132
132
|
# skip scopes that are not defined
|
133
|
-
next if params[scope_name]
|
133
|
+
next if self.blank_param?(params[scope_name])
|
134
134
|
|
135
135
|
# now apply the arguments
|
136
136
|
args_to_pass = self.get_dynamic_scope_args(
|
@@ -164,6 +164,16 @@ module Autoscope
|
|
164
164
|
return scope
|
165
165
|
end
|
166
166
|
|
167
|
+
#
|
168
|
+
# Is this data blank?
|
169
|
+
#
|
170
|
+
# @param data [String, Hash]
|
171
|
+
#
|
172
|
+
# @return [Boolean]
|
173
|
+
def blank_param?(data)
|
174
|
+
data.blank? || data.try(:values).try(:all?, &:blank?)
|
175
|
+
end
|
176
|
+
|
167
177
|
#
|
168
178
|
# Get the appropriate args from dynamic scopes
|
169
179
|
#
|
data/lib/autoscope/version.rb
CHANGED
@@ -19,6 +19,10 @@ module Autoscope
|
|
19
19
|
|
20
20
|
Post.class_eval do
|
21
21
|
|
22
|
+
scope :blank_arg_scope, -> user_id {
|
23
|
+
where(user_id: user_id)
|
24
|
+
}
|
25
|
+
|
22
26
|
scope :user_id_scope, -> user_id {
|
23
27
|
where(user_id: user_id)
|
24
28
|
}
|
@@ -84,15 +88,18 @@ module Autoscope
|
|
84
88
|
.with('req')
|
85
89
|
.returns(scope)
|
86
90
|
|
91
|
+
scope.expects(:blank_arg_scope).never
|
92
|
+
|
87
93
|
Post.add_scopes(
|
88
94
|
{
|
95
|
+
blank_arg_scope: { user_id: '' },
|
89
96
|
user_id_scope: { user_id: '1' },
|
90
97
|
two_param_scope: {
|
91
98
|
id1: '1',
|
92
99
|
id2: '2'
|
93
100
|
},
|
94
101
|
vararg_scope: { ids: %w{1 2 3} },
|
95
|
-
optional_arg_scope: { a: 'req' }
|
102
|
+
optional_arg_scope: { a: 'req' },
|
96
103
|
},
|
97
104
|
scope
|
98
105
|
)
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: autoscope
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Dan Langevin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-09-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|