cyrax 0.0.5 → 0.0.6
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
|
-
|
4
|
+
NTlkMjQyMDlmODY0ZjRjNzExNDA1ZmVmMzM0ZDIyNzI0OWYyNjg0OA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MzZkNDBhYzJlZWM2NWFmMjI1OTlhMGFkNjE1OWQxYWU5NTYxYjI2ZQ==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ODM4ZmU4ZmQxMjI4NDRiMTMwNmEyMDg4YzZkMTJhMTA0YmE1NGYzMWQ0MWVj
|
10
|
+
ZDc1MzljY2U4YThiYmNlODQ4MmUzMTNmYTRmMDgyOTczMjFlMTA4MDQzM2Jl
|
11
|
+
YWYxODZjMjQ5MTViNDc5ZDUzYjhlNTNhMzVjYzAzNWE3YjdkNmI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YjZkZTc1NDgzMGUzZGExNDllNDJiYjY1Mjk1ZDk5NTgxMmNhNDc5ZTA3NzZi
|
14
|
+
MTE3MDU5ZGM4NmM5YzY2YjAyMDdlMzQ2Y2E4M2ZkZDkzOWJhOTRhOTJlYTY3
|
15
|
+
NTc1MDE4OWQ5OGZjZmIxZTY4OTc3MjgyY2NkMzcyNWE0NjgwNGY=
|
@@ -13,11 +13,7 @@ module Cyrax::Extensions
|
|
13
13
|
end
|
14
14
|
|
15
15
|
def decorated_collection
|
16
|
-
|
17
|
-
build_decorated_collection
|
18
|
-
else
|
19
|
-
build_collection
|
20
|
-
end
|
16
|
+
decorable? ? build_decorated_collection : wrapped_collection
|
21
17
|
end
|
22
18
|
|
23
19
|
private
|
@@ -30,7 +26,7 @@ module Cyrax::Extensions
|
|
30
26
|
self.class.decorator_class_name.to_s.classify.constantize
|
31
27
|
end
|
32
28
|
|
33
|
-
def
|
29
|
+
def wrapped_collection
|
34
30
|
collection = build_collection
|
35
31
|
|
36
32
|
if collection.kind_of?(Array)
|
@@ -43,7 +39,7 @@ module Cyrax::Extensions
|
|
43
39
|
end
|
44
40
|
|
45
41
|
def build_decorated_collection
|
46
|
-
|
42
|
+
wrapped_collection.map{|i| decorator_class.new(i)}
|
47
43
|
end
|
48
44
|
end
|
49
45
|
end
|
data/lib/cyrax/version.rb
CHANGED
@@ -31,7 +31,7 @@ module Cyrax
|
|
31
31
|
|
32
32
|
subject { Cyrax::BaseResource.new }
|
33
33
|
let(:resource) { mock.as_null_object }
|
34
|
-
let(:collection) { mock }
|
34
|
+
let(:collection) { [mock] }
|
35
35
|
before do
|
36
36
|
subject.stub!(:params).and_return({id:123})
|
37
37
|
subject.stub!(:find_resource).and_return(resource)
|
@@ -69,7 +69,7 @@ module Cyrax
|
|
69
69
|
describe '#build_decorated_collection' do
|
70
70
|
before do
|
71
71
|
self.class.decorator(:foo)
|
72
|
-
subject.stub!(:
|
72
|
+
subject.stub!(:wrapped_collection).and_return([:bar])
|
73
73
|
end
|
74
74
|
|
75
75
|
it 'returns array of decorator instances' do
|
@@ -78,7 +78,7 @@ module Cyrax
|
|
78
78
|
end
|
79
79
|
|
80
80
|
describe '#prepare_collection_for_decorate' do
|
81
|
-
subject { self.send(:
|
81
|
+
subject { self.send(:wrapped_collection) }
|
82
82
|
|
83
83
|
context 'when #build_collection returns array' do
|
84
84
|
before { self.stub!(:build_collection).and_return([:bar]) }
|