cyrax 0.5.2 → 0.5.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/lib/cyrax/extensions/has_response.rb +1 -0
- data/lib/cyrax/response.rb +1 -1
- data/lib/cyrax/serializer.rb +4 -0
- data/lib/cyrax/serializers/scope.rb +11 -0
- data/lib/cyrax/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NmIyODJjMDljMjllMmJkNzM0YmM4ZTY3ZDE5OGFjMTBhYjZjZTRkNQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
MjU3NTYzNWU4NGMwNWJlYjNiYjFkOTRmNzM1YjUxMjgyN2E3YTcxNw==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MjYzNWRkNDlhMGRkN2YyOWU3NzlkYjI3YWFkNmVmYmRmNTRiNzY2NTQzZTIx
|
10
|
+
Y2E1OTJmMWI4NTUwMzBkYzg4YmM4NDgyZGNkMjk2YTEwOWE3MDM5NDhjNmIy
|
11
|
+
YmRhZTVjZDdkYTljZTQ3Njc3OWM3MmNlOGM5NDhiZDllMDllYTg=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
N2Q2MjYyYzViNjljM2I4ZWYyZjYwYTM5ZDNhMjZjNjk4YWJjMmVlODAwMDRj
|
14
|
+
N2RjZmE1ZGQwMjcyNDBiNWY3MWU3ZDQzODI3YTZkNjliMTdhYTMxMTVjMjQ5
|
15
|
+
NjFlZGZiNGQ1ODM3OWViN2QxNmNlODQyMmZmZTllODc4MmE4MTA=
|
@@ -82,6 +82,7 @@ module Cyrax::Extensions
|
|
82
82
|
# @param options [Hash] Options
|
83
83
|
def respond_with(result, options = {})
|
84
84
|
options[:as] ||= accessor
|
85
|
+
options[:assignments] = @_assignments
|
85
86
|
name = options[:name] || response_name
|
86
87
|
result = result.result.to_model if result.is_a?(Cyrax::Response)
|
87
88
|
if sync_errors_with?(result)
|
data/lib/cyrax/response.rb
CHANGED
data/lib/cyrax/serializer.rb
CHANGED
@@ -5,6 +5,7 @@ module Cyrax::Serializers
|
|
5
5
|
@dynamic_attrs = {}
|
6
6
|
@relation_attrs = {}
|
7
7
|
@namespace_attrs = {}
|
8
|
+
@assigned_attrs = {}
|
8
9
|
@default_attributes = false
|
9
10
|
instance_eval(&block) if block_given?
|
10
11
|
end
|
@@ -13,6 +14,10 @@ module Cyrax::Serializers
|
|
13
14
|
@namespace_attrs[name] = self.class.new(&block)
|
14
15
|
end
|
15
16
|
|
17
|
+
def assigned(name, &block)
|
18
|
+
@assigned_attrs[name] = self.class.new(&block)
|
19
|
+
end
|
20
|
+
|
16
21
|
def relation(attribute, &block)
|
17
22
|
if block_given?
|
18
23
|
@relation_attrs[attribute] = self.class.new(&block)
|
@@ -20,6 +25,8 @@ module Cyrax::Serializers
|
|
20
25
|
@attrs[attribute] = attribute
|
21
26
|
end
|
22
27
|
end
|
28
|
+
alias_method :has_many, :relation
|
29
|
+
alias_method :has_one, :relation
|
23
30
|
|
24
31
|
def default_attributes
|
25
32
|
@default_attributes = true
|
@@ -59,6 +66,10 @@ module Cyrax::Serializers
|
|
59
66
|
value = resource.send(attribute)
|
60
67
|
result[attribute] = scope.serialize(value)
|
61
68
|
end
|
69
|
+
@assigned_attrs.map do |attribute, scope|
|
70
|
+
value = options[:assignments][attribute]
|
71
|
+
result[attribute] = scope.serialize(value)
|
72
|
+
end
|
62
73
|
@namespace_attrs.map do |attribute, scope|
|
63
74
|
result[attribute] = scope.serialize(resource)
|
64
75
|
end
|
data/lib/cyrax/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cyrax
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Droidlabs
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-03-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -152,3 +152,4 @@ test_files:
|
|
152
152
|
- spec/cyrax/response_spec.rb
|
153
153
|
- spec/cyrax/serializer_spec.rb
|
154
154
|
- spec/spec_helper.rb
|
155
|
+
has_rdoc:
|