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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YTRmMzdlY2U1ZGM3NTRjMzJkMmYxNGZlZDZiN2JkMjFkYzE1ZDYzYg==
4
+ OThlZWVlZmUwMzdkMTk1MmVlNDVhOTg5MjUxYTk2NDYyYTUwODgzYQ==
5
5
  data.tar.gz: !binary |-
6
- N2FiMDBkN2FmNDk1YmMwNzEyNWE1Njc5YTA0ZThlMDE1OWJhNzdhYQ==
6
+ MTg5MGQzZGZkMTBlY2U0NjFjYjA4NzQzOTY1MjYyZDMwZDIxNGI5Yw==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- ZWI4NTgzYmIxNTQzZTgzYTBjOWZmZDY2NTUzOThlOTdhYWQ4ODVjYmMwZTAz
10
- NzZiMGY3ZmZiYzI5M2RmNGEwODA5NTgwNTFlODcyMzc1NTExOTEzMmJiNjg1
11
- MWY3Yjg1YTBlOGUyODdmZTU5MDY3MWRlMzA0ZWRjNmE0OWM2ZWY=
9
+ Y2Y2ZmJjOTEzZmE5YWUzZjczYzliMzg5ZWQxZTZkZjY2NGYwZmU3OGFhNTM3
10
+ NDZlNWZjZjQxOTkyNjI1OTNkYzNjMjliY2Y4MTc0NjJlMGZkMzFlNTMwMzAy
11
+ MzRlYjkzZmI1ZTNhOTNmMzk3ZDA1NGE4NWEyY2NkOGZiMGNhZmM=
12
12
  data.tar.gz: !binary |-
13
- NTVmOWYyNGE3ZjA0OTZlZWQ5MGEyNGY5NzIwMDgyYmUwNWM3NjI3MDAwNTE1
14
- ZDE5YzcxMjZjMDkwODk2YmQxMjZhNDQxM2MzMzZjZGJmMWY4MDFlZmY1NWNh
15
- NmFmZTYxYWZmYTgwY2ZkNTE5Njk5NDgzMzdkODhkMWM3MzllM2I=
13
+ NTcyODczZjRiYmY2YTJkY2QzMzFhNDUzNmJkYzdhOTk5ZTMxNzNlY2JjMGRk
14
+ YTczYzNlNjkzY2IwNjNhZDI2OTNiY2RjNGM3ZjVlOWJjNTIwZDc4MzBhMGFj
15
+ Njg3YWFiNmZjMWE0OTYwODhiMzhmMzNlMmViNDcyMjU4YjAwN2E=
@@ -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
@@ -1,3 +1,3 @@
1
1
  module ScopeComposer
2
- VERSION = "0.3.5"
2
+ VERSION = "0.4.0"
3
3
  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
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: scope_composer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.5
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Blake Hilscher