scope_composer 0.3.0 → 0.3.1
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 +8 -8
- data/UPGRADE.md +6 -0
- data/lib/scope_composer/scope.rb +3 -3
- data/lib/scope_composer/version.rb +1 -1
- data/spec/scope_composer/model_spec.rb +8 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
MWZiN2E2N2U1MTQ2YjQ3MTY3MGI5ZWE4NTQ4MTMwYjIxZmU1MTQ5Mw==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NmY5ZTUyYjE1MzE0YjM2ZjNmM2NiYjgyZDU2NTY5NmQxNDU5NmFlNA==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
Njg2NjA0MDVhZDAxOGE2ZWFlNzNmZTJkMmM4MTUwOTZlY2E3NTdkODdhYTAw
|
10
|
+
Yjk5NjE1N2FhYmZkMWE4ZDVmYzAxM2M3Njk3YzdlZWU0MTY0OGZjMTJiYWM2
|
11
|
+
M2I3NTBlYjVjZTc0MDAwNjYwY2RjYWI2YTUwMzNhNzM0ZjA0ZmU=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NGY5NDg4ZTM1ZWZkZThhYTQ0YzAxM2EyYTRmZWI5NzMzMGRjNGQ0OGMwMjI2
|
14
|
+
ZTVhN2IzZGZjNjY5MjcyZDVjMTE3ZWE3YzQyYmQyMWE4ZWQ5OTU4ZmEyZjBm
|
15
|
+
Zjg2Njc1YWExYmI1MjA0OWU0NTAzYjU5ZGRiYmFlNzMzODg3OGM=
|
data/UPGRADE.md
CHANGED
data/lib/scope_composer/scope.rb
CHANGED
@@ -116,11 +116,11 @@ class Scope
|
|
116
116
|
# define method
|
117
117
|
define_method(name) do |*args|
|
118
118
|
# init
|
119
|
-
|
119
|
+
values = args.count == 1 ? args.first : args
|
120
120
|
# if no value is given, act as a getter
|
121
|
-
return scope_attributes[name] if
|
121
|
+
return scope_attributes[name] if values.nil?
|
122
122
|
# otherwise set the value
|
123
|
-
scope_attributes[name] =
|
123
|
+
scope_attributes[name] = values
|
124
124
|
# and return self for chaining
|
125
125
|
return self
|
126
126
|
end
|
@@ -11,6 +11,7 @@ describe ScopeComposer::Model do
|
|
11
11
|
scope_helper :helper_method, ->(t){ 'hi' }
|
12
12
|
|
13
13
|
scope_composer_for :search
|
14
|
+
search_scope :select
|
14
15
|
search_scope :limit
|
15
16
|
search_scope :offset, prefix: true
|
16
17
|
search_helper :tester, ->(t){ t.to_i }
|
@@ -43,6 +44,13 @@ describe ScopeComposer::Model do
|
|
43
44
|
its(:scope_attributes){ should eq({ limit: 10 }) }
|
44
45
|
its(:attributes){ should eq({}) }
|
45
46
|
|
47
|
+
describe "#select" do
|
48
|
+
before(:each){ scope.select(:key1, :key2, :key3) }
|
49
|
+
|
50
|
+
its(:scope_attributes){ should eq({ limit: 10, select: [:key1, :key2, :key3] }) }
|
51
|
+
|
52
|
+
end
|
53
|
+
|
46
54
|
describe "#where" do
|
47
55
|
before(:each){ scope.where( id: 20 ) }
|
48
56
|
|