id 0.0.4 → 0.0.5

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- id (0.0.3)
4
+ id (0.0.4)
5
5
  activesupport
6
6
 
7
7
  GEM
data/id.gemspec CHANGED
@@ -1,6 +1,6 @@
1
1
  Gem::Specification.new do |s|
2
2
  s.name = 'id'
3
- s.version = '0.0.4'
3
+ s.version = '0.0.5'
4
4
  s.date = '2013-03-28'
5
5
  s.summary = "Simple models based on hashes"
6
6
  s.description = "Developed at On The Beach Ltd. Contact russell.dunphy@onthebeach.co.uk"
@@ -3,7 +3,7 @@ module Id
3
3
  attr_reader :data
4
4
 
5
5
  def initialize(data)
6
- @data = Hash[data.map { |k, v| [k.to_s, v] }]
6
+ @data = Hash[data.map { |k, v| [k.to_s, v.is_a?(Id::Model) ? v.data : v] }]
7
7
  end
8
8
 
9
9
  def set(values)
@@ -32,6 +32,14 @@ describe Id::Model do
32
32
  nested_models: [{ 'yak' => 11}, { yak: 14 }],
33
33
  extra_nested_model: { cats!: "MIAOW" }) }
34
34
 
35
+
36
+ describe ".new" do
37
+ it 'converts any passed id models to their hash representations' do
38
+ new_model = TestModel.new(test_model: model)
39
+ new_model.test_model.data.should eq model.data
40
+ end
41
+ end
42
+
35
43
  describe ".field" do
36
44
  it 'defines an accessor on the model' do
37
45
  model.foo.should eq 3
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: id
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: