scope_composer 0.3.5 → 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 +8 -8
- data/lib/scope_composer/scope.rb +7 -0
- data/lib/scope_composer/version.rb +1 -1
- data/spec/scope_composer/model_spec.rb +16 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
OThlZWVlZmUwMzdkMTk1MmVlNDVhOTg5MjUxYTk2NDYyYTUwODgzYQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MTg5MGQzZGZkMTBlY2U0NjFjYjA4NzQzOTY1MjYyZDMwZDIxNGI5Yw==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
Y2Y2ZmJjOTEzZmE5YWUzZjczYzliMzg5ZWQxZTZkZjY2NGYwZmU3OGFhNTM3
|
10
|
+
NDZlNWZjZjQxOTkyNjI1OTNkYzNjMjliY2Y4MTc0NjJlMGZkMzFlNTMwMzAy
|
11
|
+
MzRlYjkzZmI1ZTNhOTNmMzk3ZDA1NGE4NWEyY2NkOGZiMGNhZmM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NTcyODczZjRiYmY2YTJkY2QzMzFhNDUzNmJkYzdhOTk5ZTMxNzNlY2JjMGRk
|
14
|
+
YTczYzNlNjkzY2IwNjNhZDI2OTNiY2RjNGM3ZjVlOWJjNTIwZDc4MzBhMGFj
|
15
|
+
Njg3YWFiNmZjMWE0OTYwODhiMzhmMzNlMmViNDcyMjU4YjAwN2E=
|
data/lib/scope_composer/scope.rb
CHANGED
@@ -133,6 +133,13 @@ class Scope
|
|
133
133
|
|
134
134
|
delegate :to_param, to: :attributes
|
135
135
|
|
136
|
+
def scoped
|
137
|
+
s = self.class.new
|
138
|
+
s.attributes = attributes.clone
|
139
|
+
s.scope_attributes = scope_attributes.clone
|
140
|
+
s
|
141
|
+
end
|
142
|
+
|
136
143
|
def read_scope_attribute(key)
|
137
144
|
scope_attributes[key]
|
138
145
|
end
|
@@ -65,6 +65,22 @@ describe ScopeComposer::Model do
|
|
65
65
|
its(:attributes){ should eq({ id: 20 }) }
|
66
66
|
end
|
67
67
|
|
68
|
+
describe "#scoped" do
|
69
|
+
before(:each){ scope.where( id: 20 ) }
|
70
|
+
subject{ scope.scoped }
|
71
|
+
|
72
|
+
its(:attributes){ should eq({ id: 20 }) }
|
73
|
+
|
74
|
+
it "should not alter the original object" do
|
75
|
+
scope.where( id: 30 )
|
76
|
+
subject.where( id: 40 )
|
77
|
+
scope.attributes.should eq({id: 30})
|
78
|
+
subject.attributes.should eq({id: 40})
|
79
|
+
end
|
80
|
+
|
81
|
+
|
82
|
+
end
|
83
|
+
|
68
84
|
end
|
69
85
|
|
70
86
|
describe ".scope" do
|