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 CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- YTk1NzA2YTkzMjQzMzQ4NTdlNzIxYWEzYzE3ZTFjY2Y3ZjIyNDE0NA==
4
+ YmEyMTVhYzkxNzUxYTZhZTIzOTZiMGI3YTVkZTU5ZTc4NWE5YjBiOA==
5
5
  data.tar.gz: !binary |-
6
- MjA3NWY4YjNlMjRjNjU5Zjc2NDE2Zjc3MWRkZmRjMmMxNjUwNWU0Nw==
6
+ MWZjMGI1ZjljNjQ2M2UwZWE4NzI0YmJkYzAyOGY4NzE0ZTM0MTc4Nw==
7
7
  !binary "U0hBNTEy":
8
8
  metadata.gz: !binary |-
9
- MjlkNjFjMTRjYjVhMzVhYTk4OTNhNmIzMDQ4OTk2NDMyZDI0ZjQ2MzlkYWVj
10
- ZmVmMWUxNThlMWVhMGFmNDBhN2M4NzFmYTU0Mjk5MTEwZmMyZTNiMWRiNGYy
11
- YTE1OTgxMzNiOWRjN2Y0ZmZlMGMxZWViMTc5Yzg1YmRkOWQzMzA=
9
+ ZmJmMzEyMmFiNzk0ZmY4OGNhMDBmODc2Mzc4ZWNiODE2YzI2MDhhYmYxNjk0
10
+ MDkwNTFlZjM5YWMzMjFhZWJkNDI4MGM4NjY4YjRkZThlYWVhYWE5MzczZTJk
11
+ YmM3OWNmMTg2NzMwNzYyNGE3YmJjOGY5ZDQzOWRmYjk3OWI5YmM=
12
12
  data.tar.gz: !binary |-
13
- YzAwMjA4MWEwNzI3M2E1ZjgyNjllMGRlOWY3NWZkZjMwM2ViOWY5MDA2ZDZi
14
- YmIxOGUwMWQ3NTc1Yjg2MjY2ZGY1YmZhOWMzNTljODI1NzlkZjI0MmEwOTI0
15
- OGQwOWE2MzJiY2NlYjNhMDA1ZmQ5YjE2NDg4OWZjNzlkYzdhMzI=
13
+ MTkxOGM0NzMzZGM5NmM1NjhlOWYwNDFlZGNmOTU4ZmM3Y2NjNDI2NjcyNDI0
14
+ YmEzOTFhZTQ1YmIxZDVjNDU5MDY3NWY2MzFmYjBmNTVkNGJjODJiYjEzZmMx
15
+ MDE0Mjk3NjY4Yzc1MzdhMDMxM2VmODIwZmExOTI4YWMzNzE1NTA=
@@ -39,6 +39,10 @@ class Cyrax::Response
39
39
  errors && errors.include?(error)
40
40
  end
41
41
 
42
+ def as_json(*args)
43
+ result.as_json(*args)
44
+ end
45
+
42
46
  def method_missing(method, *args, &block)
43
47
  super unless assignments.has_key?(method)
44
48
  assignments[method]
@@ -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].instance_eval(&block)
45
+ result[attribute] = options[:serializer].instance_exec(resource, &block)
38
46
  end
39
47
  result
40
48
  end
@@ -1,3 +1,3 @@
1
1
  module Cyrax
2
- VERSION = "0.3.3"
2
+ VERSION = "0.3.4"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cyrax
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Droidlabs