conglomerate 0.2.0 → 0.2.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 +4 -4
- data/lib/conglomerate/serializer.rb +8 -4
- data/lib/conglomerate/version.rb +1 -1
- data/spec/conglomerate_spec.rb +2 -15
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 79cf2a21f974567cdf55b0a1e273292306c96140
|
4
|
+
data.tar.gz: 882941211d941acbd16c88eefb0e51c0fad474bc
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 57d389ee559e86c32166f58fc6efbcc9a23d57a5c3dbadca1318ef0735ae366f46cea65ddc2f62bbf97014ee5bc363c21b6a107a6118e8e25d30a12676d4903f
|
7
|
+
data.tar.gz: 568b17ac4a3c9bb36ec93aa8133926d6d42f39c0407351692eaa5b3a458682067fd7d5e514f337e74f350ec501a09c3db0fca35293ded8bf99a670ab2fe73226
|
@@ -30,10 +30,14 @@ module Conglomerate
|
|
30
30
|
end
|
31
31
|
|
32
32
|
def apply_href(collection, proc: self.class._href, object: nil)
|
33
|
-
if
|
34
|
-
|
33
|
+
if proc
|
34
|
+
if object
|
35
|
+
collection.merge({"href" => context.instance_exec(object, &proc)})
|
36
|
+
else
|
37
|
+
collection.merge({"href" => context.instance_eval(&proc)})
|
38
|
+
end
|
35
39
|
else
|
36
|
-
collection
|
40
|
+
collection
|
37
41
|
end
|
38
42
|
end
|
39
43
|
|
@@ -189,7 +193,7 @@ module Conglomerate
|
|
189
193
|
attr_writer :_href, :_item_href, :_queries, :_attributes, :_links
|
190
194
|
|
191
195
|
def _href
|
192
|
-
@_href ||
|
196
|
+
@_href || nil
|
193
197
|
end
|
194
198
|
|
195
199
|
def _item_href
|
data/lib/conglomerate/version.rb
CHANGED
data/spec/conglomerate_spec.rb
CHANGED
@@ -34,18 +34,11 @@ end
|
|
34
34
|
class ConglomerateExtraTestSerializer
|
35
35
|
include Conglomerate.serializer
|
36
36
|
|
37
|
-
href { "" }
|
38
37
|
attribute :id
|
39
38
|
end
|
40
39
|
|
41
40
|
class ConglomerateNullSerializer
|
42
41
|
include Conglomerate.serializer
|
43
|
-
|
44
|
-
href { "" }
|
45
|
-
end
|
46
|
-
|
47
|
-
class ConglomerateInvalidSerializer
|
48
|
-
include Conglomerate.serializer
|
49
42
|
end
|
50
43
|
|
51
44
|
describe Conglomerate do
|
@@ -96,18 +89,12 @@ describe Conglomerate do
|
|
96
89
|
ConglomerateNullSerializer.new(object, :context => context).serialize
|
97
90
|
end
|
98
91
|
|
99
|
-
let(:invalid_serializer) do
|
100
|
-
ConglomerateInvalidSerializer.new(object, :context => context).serialize
|
101
|
-
end
|
102
|
-
|
103
92
|
let(:test_collection) { test_serializer["collection"] }
|
104
93
|
|
105
94
|
let(:extra_test_collection) { extra_test_serializer["collection"] }
|
106
95
|
|
107
96
|
let(:null_collection) { null_serializer["collection"] }
|
108
97
|
|
109
|
-
let(:invalid_collection) { invalid_serializer["collection"] }
|
110
|
-
|
111
98
|
describe "#version" do
|
112
99
|
it "sets version to 1.0" do
|
113
100
|
expect(null_collection["version"]).to eq("1.0")
|
@@ -120,8 +107,8 @@ describe Conglomerate do
|
|
120
107
|
expect(test_collection["href"]).to eq("abc")
|
121
108
|
end
|
122
109
|
|
123
|
-
it "
|
124
|
-
expect
|
110
|
+
it "isn't included if the href is nil" do
|
111
|
+
expect(null_collection["href"]).to be_nil
|
125
112
|
end
|
126
113
|
end
|
127
114
|
|