cyrax 0.3.3 → 0.3.4
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/cyrax/response.rb +4 -0
- data/lib/cyrax/serializer.rb +2 -2
- data/lib/cyrax/serializers/scope.rb +9 -1
- data/lib/cyrax/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
YmEyMTVhYzkxNzUxYTZhZTIzOTZiMGI3YTVkZTU5ZTc4NWE5YjBiOA==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MWZjMGI1ZjljNjQ2M2UwZWE4NzI0YmJkYzAyOGY4NzE0ZTM0MTc4Nw==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZmJmMzEyMmFiNzk0ZmY4OGNhMDBmODc2Mzc4ZWNiODE2YzI2MDhhYmYxNjk0
|
10
|
+
MDkwNTFlZjM5YWMzMjFhZWJkNDI4MGM4NjY4YjRkZThlYWVhYWE5MzczZTJk
|
11
|
+
YmM3OWNmMTg2NzMwNzYyNGE3YmJjOGY5ZDQzOWRmYjk3OWI5YmM=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MTkxOGM0NzMzZGM5NmM1NjhlOWYwNDFlZGNmOTU4ZmM3Y2NjNDI2NjcyNDI0
|
14
|
+
YmEzOTFhZTQ1YmIxZDVjNDU5MDY3NWY2MzFmYjBmNTVkNGJjODJiYjEzZmMx
|
15
|
+
MDE0Mjk3NjY4Yzc1MzdhMDMxM2VmODIwZmExOTI4YWMzNzE1NTA=
|
data/lib/cyrax/response.rb
CHANGED
data/lib/cyrax/serializer.rb
CHANGED
@@ -17,8 +17,8 @@ class Cyrax::Serializer < Cyrax::Wrapper
|
|
17
17
|
scope.attributes(*attrs)
|
18
18
|
end
|
19
19
|
|
20
|
-
def attribute(attribute, options = {})
|
21
|
-
scope.attribute(attribute, options)
|
20
|
+
def attribute(attribute, options = {}, &block)
|
21
|
+
scope.attribute(attribute, options, &block)
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
@@ -25,6 +25,14 @@ module Cyrax::Serializers
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def serialize(resource, options = {})
|
28
|
+
if resource.is_a?(Array)
|
29
|
+
resource.map{ |r| serialize_one(r, options) }
|
30
|
+
else
|
31
|
+
serialize_one(resource, options)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def serialize_one(resource, options = {})
|
28
36
|
result = {}
|
29
37
|
@attrs.map do |attribute, options|
|
30
38
|
value = resource.send(attribute)
|
@@ -34,7 +42,7 @@ module Cyrax::Serializers
|
|
34
42
|
result[attribute] = value
|
35
43
|
end
|
36
44
|
@dynamic_attrs.map do |attribute, block|
|
37
|
-
result[attribute] = options[:serializer].
|
45
|
+
result[attribute] = options[:serializer].instance_exec(resource, &block)
|
38
46
|
end
|
39
47
|
result
|
40
48
|
end
|
data/lib/cyrax/version.rb
CHANGED