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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ececce0f435338b1fcd8df20a1cad2be6b7ce55d
4
- data.tar.gz: 249d51c79b4adbf5555958964ea24856866ef610
3
+ metadata.gz: 06a2e5ace6afb79bf0a875113e4a88c1fbf73388
4
+ data.tar.gz: 082abc21ba19011f301817d2df10d8b581c199da
5
5
  SHA512:
6
- metadata.gz: e995deb43d9d2e40686d073293e24eb07b19e09f2704db7f775d11be74cbb808e7d7ae4865ab7988467c80fd2cbbaf9231717cacfd764ae5904bc5d19b99c103
7
- data.tar.gz: f5dc858c55d40b0ebd28af8e038f4f0012a19e03bd74e75541a64af75e39d5f6c77d7fb5c9db4526867a7a70ffb8aee90110f2984acb5a78f8d11f17c5dcb323
6
+ metadata.gz: fca6784ae81cec7e4c030d83b0fd852b743e7e360f37524cff294aa719b1dc9baebdabeab9776ad51a8a8d3e67290177595939ca46b5fb2d5268e97d40bb49bb
7
+ data.tar.gz: b9acd9e3f996b41d4f0cc2a8803020442d9c40debac6302ab8af8af37374f98e7ad41c7b4e9ed6584b5b224ddad76635eabcf6cecc02557c7d4fe1f53fd4fd1c
@@ -62,7 +62,12 @@ class Cyrax::Response
62
62
  end
63
63
 
64
64
  def method_missing(method, *args, &block)
65
- super unless assignments.has_key?(method)
66
- assignments[method]
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.respond_to?(:to_a)
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)
@@ -1,3 +1,3 @@
1
1
  module Cyrax
2
- VERSION = "0.5.8"
2
+ VERSION = "0.5.9"
3
3
  end
@@ -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.8
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: 2014-08-08 00:00:00.000000000 Z
11
+ date: 2015-09-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport