cyrax 0.7.0 → 0.7.1
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
- data/spec/cyrax/extensions/has_response_spec.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NmVmYTYxMjdjYjFjNzQ3NDZlMmY1NTU4MzNlNjE0ZDE2MzYyMTA1Mg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
NWFlM2YxZWI2Y2FjODRhNWVjYzg0ZTIyNDgyOGM4MWMzMTAyZGI4Yg==
|
7
7
|
!binary "U0hBNTEy":
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
NTExZjYzODQwYjgwYjNjNTY4MTQzNzNkOTMzMjQ4NjA1ZTZmNmFhYWVkYjBm
|
10
|
+
Y2FmOGU2ZGFjZTljNDdjOGI4NmI1MTg2YzhhZmZlMjJiNmQyZGIwM2YwYTA1
|
11
|
+
ZTcyYzRmNDEzOGRkZDIzYTIxYTg5NmUwZjY1MjRkYzVhMzdhMWI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
MGNiNjhjODJmMzk1M2RkNDlkOTBkYzE3OTk1NmE4YjBhODBiYmIyNjRlNmM4
|
14
|
+
OWU2YzYyNmE4NTViZTBmMGUxNzFkYWZlYjljODllZDU4OTUzNDRlMmJkZjI5
|
15
|
+
MTRjYjk2MTUxNGRkOGRlZjZkMzllNmFiYzBlODZjMWJiYTFhNTg=
|
@@ -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
|
@@ -62,6 +69,10 @@ module Cyrax::Serializers
|
|
62
69
|
@namespace_attrs.map do |attribute, scope|
|
63
70
|
result[attribute] = scope.serialize(resource)
|
64
71
|
end
|
72
|
+
@assigned_attrs.map do |attribute, scope|
|
73
|
+
value = options[:assignments][attribute]
|
74
|
+
result[attribute] = scope.serialize(value)
|
75
|
+
end
|
65
76
|
@attrs.map do |attribute, options|
|
66
77
|
result[attribute] = resource.send(attribute)
|
67
78
|
end
|
data/lib/cyrax/version.rb
CHANGED
@@ -59,7 +59,7 @@ module Cyrax
|
|
59
59
|
describe '#respond_with' do
|
60
60
|
before { subject.stub(:response_name).and_return(:foo) }
|
61
61
|
it 'calls Cyrax::Response' do
|
62
|
-
Cyrax::Response.should_receive(:new).with(:foo, 'bar', {as: nil}).and_return(double.as_null_object)
|
62
|
+
Cyrax::Response.should_receive(:new).with(:foo, 'bar', {as: nil, assignments: nil}).and_return(double.as_null_object)
|
63
63
|
subject.respond_with('bar')
|
64
64
|
end
|
65
65
|
|
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.7.
|
4
|
+
version: 0.7.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Droidlabs
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-03-12 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|