oat 0.1.1 → 0.1.2

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: 0301b4c113c6202d3f7ba67f5c4acb07c3021407
4
- data.tar.gz: b35bb46fe71c4334bb37fec794fd160ab8654414
3
+ metadata.gz: bf0df88db08a4e8499e855c3297040d5a5624bb1
4
+ data.tar.gz: 52a898fa03b0a1e043da33169334a3c40ce981e0
5
5
  SHA512:
6
- metadata.gz: c641981d4467f2fcf9793b322269bbabd055f334b2c9568dd0df40c5a82d8d84d5f76a0a3a83a9bd644f56172dda578481fe23620e40207b516116129330955d
7
- data.tar.gz: 08ea3bad413a1c6c2655a8ad6d9491d2cb1f47aedd2bb745c46b0ad2307cbcae5fc5556cef14db2baaa4608f2ed0a18ea80331c1b88c77375dda2b152d0da617
6
+ metadata.gz: 76dc4f30fabc30a43962e608895c1036cc627923e95c0a4dda092b3e5a83c4e0f1b625d14975fd81b2df382d9615e9b8b302abeb8c040a6cbeca061acc0c677c
7
+ data.tar.gz: 7b9e468b4ca49e14b54d98d8342fa92254809600e0c93b22fece7ba88bf424c4bd61b36d07e9ea4c86bdb6d2cfd5f0f48fa3227b41c77c8bd1318deabe86aa78
@@ -29,7 +29,7 @@ module Oat
29
29
  @entities[name.to_s.pluralize.to_sym] ||= []
30
30
  ent = entity_without_root(obj, serializer_class, &block)
31
31
  if ent
32
- link name, href: ent[:id]
32
+ link name, :href => ent[:id]
33
33
  @entities[name.to_s.pluralize.to_sym] << ent
34
34
  end
35
35
  end
@@ -15,7 +15,7 @@ module Oat
15
15
  end
16
16
 
17
17
  def link(rel, opts = {})
18
- data[:links] << {rel: [rel]}.merge(opts)
18
+ data[:links] << {:rel => [rel]}.merge(opts)
19
19
  end
20
20
 
21
21
  def properties(&block)
@@ -48,7 +48,7 @@ module Oat
48
48
  attr_reader :data
49
49
 
50
50
  def initialize(name)
51
- @data = { name: name, class: [], fields: [] }
51
+ @data = { :name => name, :class => [], :fields => [] }
52
52
  end
53
53
 
54
54
  def class(value)
@@ -72,7 +72,7 @@ module Oat
72
72
  attr_reader :data
73
73
 
74
74
  def initialize(name)
75
- @data = { name: name }
75
+ @data = { :name => name }
76
76
  end
77
77
 
78
78
  %w(type value).each do |attribute|
data/lib/oat/props.rb CHANGED
@@ -1,10 +1,14 @@
1
1
  module Oat
2
- class Props < BasicObject
2
+ class Props
3
3
 
4
4
  def initialize
5
5
  @attributes = {}
6
6
  end
7
7
 
8
+ def id(value)
9
+ @attributes[:id] = value
10
+ end
11
+
8
12
  def _from(data)
9
13
  @attributes = data.to_hash
10
14
  end
@@ -18,4 +22,4 @@ module Oat
18
22
  end
19
23
 
20
24
  end
21
- end
25
+ end
@@ -39,6 +39,13 @@ module Oat
39
39
  end
40
40
  end
41
41
 
42
+ def type(*args)
43
+ if adapter.respond_to?(:type) && adapter.method(:type).arity != 0
44
+ adapter.type(*args)
45
+ end
46
+ end
47
+
48
+
42
49
  def respond_to_missing?(method_name, include_private = false)
43
50
  adapter.respond_to? method_name
44
51
  end
data/lib/oat/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Oat
2
- VERSION = "0.1.1"
2
+ VERSION = "0.1.2"
3
3
  end
@@ -5,7 +5,7 @@ describe Oat::Adapters::HAL do
5
5
 
6
6
  include Fixtures
7
7
 
8
- subject{ serializer_class.new(user, {name: 'some_controller'}, Oat::Adapters::HAL) }
8
+ subject{ serializer_class.new(user, {:name => 'some_controller'}, Oat::Adapters::HAL) }
9
9
 
10
10
  describe '#to_hash' do
11
11
  it 'produces a HAL-compliant hash' do
@@ -5,7 +5,7 @@ describe Oat::Adapters::JsonAPI do
5
5
 
6
6
  include Fixtures
7
7
 
8
- subject{ serializer_class.new(user, {name: 'some_controller'}, Oat::Adapters::JsonAPI) }
8
+ subject{ serializer_class.new(user, {:name => 'some_controller'}, Oat::Adapters::JsonAPI) }
9
9
 
10
10
  describe '#to_hash' do
11
11
  it 'produces a JSON-API compliant hash' do
@@ -5,7 +5,7 @@ describe Oat::Adapters::Siren do
5
5
 
6
6
  include Fixtures
7
7
 
8
- subject{ serializer_class.new(user, {name: 'some_controller'}, Oat::Adapters::Siren) }
8
+ subject{ serializer_class.new(user, {:name => 'some_controller'}, Oat::Adapters::Siren) }
9
9
 
10
10
  describe '#to_hash' do
11
11
  it 'produces a Siren-compliant hash' do
data/spec/fixtures.rb CHANGED
@@ -11,8 +11,8 @@ module Fixtures
11
11
 
12
12
  schema do
13
13
  type 'user'
14
- link :self, href: url_for(item.id)
15
- link :empty, href: nil
14
+ link :self, :href => url_for(item.id)
15
+ link :empty, :href => nil
16
16
 
17
17
  property :id, item.id
18
18
  map_properties :name, :age
@@ -24,7 +24,7 @@ module Fixtures
24
24
 
25
25
  entity :manager, item.manager do |manager, s|
26
26
  s.type 'manager'
27
- s.link :self, href: url_for(manager.id)
27
+ s.link :self, :href => url_for(manager.id)
28
28
  s.properties do |attrs|
29
29
  attrs.id manager.id
30
30
  attrs.name manager.name
@@ -54,7 +54,7 @@ describe Oat::Serializer do
54
54
 
55
55
  describe '#to_hash' do
56
56
  it 'builds Hash from item and context with attributes as defined in adapter' do
57
- serializer = @sc.new(user1, name: 'some_controller')
57
+ serializer = @sc.new(user1, :name => 'some_controller')
58
58
  serializer.to_hash.tap do |h|
59
59
  h[:attributes][:special].should == 'Hello'
60
60
  h[:attributes][:id].should == user1.id
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: oat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ismael Celis
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-01-26 00:00:00.000000000 Z
11
+ date: 2014-02-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport