cyrax 0.5.8 → 0.5.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/cyrax/response.rb +7 -2
- data/lib/cyrax/serializers/scope.rb +3 -1
- data/lib/cyrax/version.rb +1 -1
- data/spec/cyrax/serializer_spec.rb +13 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 06a2e5ace6afb79bf0a875113e4a88c1fbf73388
|
4
|
+
data.tar.gz: 082abc21ba19011f301817d2df10d8b581c199da
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fca6784ae81cec7e4c030d83b0fd852b743e7e360f37524cff294aa719b1dc9baebdabeab9776ad51a8a8d3e67290177595939ca46b5fb2d5268e97d40bb49bb
|
7
|
+
data.tar.gz: b9acd9e3f996b41d4f0cc2a8803020442d9c40debac6302ab8af8af37374f98e7ad41c7b4e9ed6584b5b224ddad76635eabcf6cecc02557c7d4fe1f53fd4fd1c
|
data/lib/cyrax/response.rb
CHANGED
@@ -62,7 +62,12 @@ class Cyrax::Response
|
|
62
62
|
end
|
63
63
|
|
64
64
|
def method_missing(method, *args, &block)
|
65
|
-
|
66
|
-
|
65
|
+
if method.to_s == resource_name
|
66
|
+
result
|
67
|
+
elsif assignments.has_key?(method)
|
68
|
+
assignments[method]
|
69
|
+
else
|
70
|
+
super
|
71
|
+
end
|
67
72
|
end
|
68
73
|
end
|
@@ -47,7 +47,9 @@ module Cyrax::Serializers
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def serialize(resource, options = {})
|
50
|
-
if resource.
|
50
|
+
if resource.nil?
|
51
|
+
nil
|
52
|
+
elsif resource.respond_to?(:to_a)
|
51
53
|
resource.to_a.map{ |r| serialize_one(r, options) }
|
52
54
|
else
|
53
55
|
serialize_one(resource, options)
|
data/lib/cyrax/version.rb
CHANGED
@@ -8,16 +8,25 @@ class FooSerializer < Cyrax::Serializer
|
|
8
8
|
relation :another do
|
9
9
|
attributes :another_foo, :another_bar
|
10
10
|
end
|
11
|
+
relation :empty_relation_many do
|
12
|
+
attributes :another_foo, :another_bar
|
13
|
+
end
|
14
|
+
relation :empty_relation_one do
|
15
|
+
attributes :another_foo, :another_bar
|
16
|
+
end
|
11
17
|
end
|
12
18
|
|
13
19
|
module Cyrax
|
14
20
|
describe FooSerializer do
|
15
|
-
let(:serializable) {
|
21
|
+
let(:serializable) {
|
16
22
|
double(
|
17
23
|
name: 'me',
|
18
24
|
foo: '2342',
|
19
25
|
bar: '4223',
|
20
|
-
another: double(another_foo: '1234', another_bar: '1234')
|
26
|
+
another: double(another_foo: '1234', another_bar: '1234'),
|
27
|
+
empty_relation_one: nil,
|
28
|
+
empty_relation_many: []
|
29
|
+
)
|
21
30
|
}
|
22
31
|
subject { FooSerializer.new(serializable).serialize }
|
23
32
|
|
@@ -25,6 +34,8 @@ module Cyrax
|
|
25
34
|
subject[:name].should eq('me')
|
26
35
|
subject[:some][:foo].should eq('2342')
|
27
36
|
subject[:another][:another_foo].should eq('1234')
|
37
|
+
subject[:empty_relation_one].should eq(nil)
|
38
|
+
subject[:empty_relation_many].should eq([])
|
28
39
|
end
|
29
40
|
end
|
30
41
|
end
|
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.9
|
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: 2015-09-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|