id 0.0.10 → 0.0.11

Sign up to get free protection for your applications and to get access to all the features.
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- id (0.0.9)
4
+ id (0.0.10)
5
5
  activemodel
6
6
  activesupport
7
7
  money
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.10'
3
+ s.version = '0.0.11'
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"
@@ -4,8 +4,8 @@ module Id
4
4
 
5
5
  def value_of(data)
6
6
  if optional?
7
- child = data.fetch(field.key, nil)
8
- child.nil? ? None : Some[field.type.new(child)]
7
+ child = data.fetch(key, nil)
8
+ child.nil? ? None : Some[type.new(child)]
9
9
  else
10
10
  child = data.fetch(key) { raise MissingAttributeError, key }
11
11
  type.new(child) unless child.nil?
@@ -1,5 +1,10 @@
1
1
  require 'spec_helper'
2
2
 
3
+ class OptionalModel
4
+ include Id::Model
5
+ field :buzz
6
+ end
7
+
3
8
  class NestedModel
4
9
  include Id::Model
5
10
  field :yak
@@ -21,6 +26,7 @@ class TestModel
21
26
  has_one :nested_model, :key => 'aliased_model'
22
27
  has_one :extra_nested_model
23
28
  has_one :test_model
29
+ has_one :optional_model, :optional => true
24
30
  has_many :nested_models
25
31
 
26
32
  class ExtraNestedModel
@@ -35,6 +41,7 @@ describe Id::Model do
35
41
  :quxx => 8,
36
42
  :test_model => {},
37
43
  :date_of_birth => '06-06-1983',
44
+ :optional_model => { 'yak' => 11},
38
45
  :aliased_model => { 'yak' => 11},
39
46
  :nested_models => [{ 'yak' => 11}, { :yak => 14 }],
40
47
  :extra_nested_model => { :cats => "MIAOW" }) }
@@ -103,6 +110,14 @@ describe Id::Model do
103
110
  it "allows recursively defined models" do
104
111
  model.test_model.should be_a TestModel
105
112
  end
113
+
114
+ it "allows optional models" do
115
+ model.optional_model.should be_some
116
+ end
117
+
118
+ it "allows optional models with correct values" do
119
+ model.optional_model.should eq Some[OptionalModel.new(:yak => 11)]
120
+ end
106
121
  end
107
122
 
108
123
  describe ".has_many" do
metadata CHANGED
@@ -1,121 +1,118 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: id
3
- version: !ruby/object:Gem::Version
4
- version: 0.0.10
3
+ version: !ruby/object:Gem::Version
4
+ hash: 9
5
5
  prerelease:
6
+ segments:
7
+ - 0
8
+ - 0
9
+ - 11
10
+ version: 0.0.11
6
11
  platform: ruby
7
- authors:
12
+ authors:
8
13
  - Russell Dunphy
9
14
  - Radek Molenda
10
15
  autorequire:
11
16
  bindir: bin
12
17
  cert_chain: []
13
- date: 2013-03-28 00:00:00.000000000 Z
14
- dependencies:
15
- - !ruby/object:Gem::Dependency
18
+
19
+ date: 2013-03-28 00:00:00 Z
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
16
22
  name: optional
17
- requirement: !ruby/object:Gem::Requirement
18
- none: false
19
- requirements:
20
- - - ! '>='
21
- - !ruby/object:Gem::Version
22
- version: '0'
23
- type: :runtime
24
23
  prerelease: false
25
- version_requirements: !ruby/object:Gem::Requirement
24
+ requirement: &id001 !ruby/object:Gem::Requirement
26
25
  none: false
27
- requirements:
28
- - - ! '>='
29
- - !ruby/object:Gem::Version
30
- version: '0'
31
- - !ruby/object:Gem::Dependency
32
- name: money
33
- requirement: !ruby/object:Gem::Requirement
34
- none: false
35
- requirements:
36
- - - ! '>='
37
- - !ruby/object:Gem::Version
38
- version: '0'
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 3
30
+ segments:
31
+ - 0
32
+ version: "0"
39
33
  type: :runtime
34
+ version_requirements: *id001
35
+ - !ruby/object:Gem::Dependency
36
+ name: money
40
37
  prerelease: false
41
- version_requirements: !ruby/object:Gem::Requirement
38
+ requirement: &id002 !ruby/object:Gem::Requirement
42
39
  none: false
43
- requirements:
44
- - - ! '>='
45
- - !ruby/object:Gem::Version
46
- version: '0'
47
- - !ruby/object:Gem::Dependency
48
- name: activesupport
49
- requirement: !ruby/object:Gem::Requirement
50
- none: false
51
- requirements:
52
- - - ! '>='
53
- - !ruby/object:Gem::Version
54
- version: '0'
40
+ requirements:
41
+ - - ">="
42
+ - !ruby/object:Gem::Version
43
+ hash: 3
44
+ segments:
45
+ - 0
46
+ version: "0"
55
47
  type: :runtime
48
+ version_requirements: *id002
49
+ - !ruby/object:Gem::Dependency
50
+ name: activesupport
56
51
  prerelease: false
57
- version_requirements: !ruby/object:Gem::Requirement
58
- none: false
59
- requirements:
60
- - - ! '>='
61
- - !ruby/object:Gem::Version
62
- version: '0'
63
- - !ruby/object:Gem::Dependency
64
- name: activemodel
65
- requirement: !ruby/object:Gem::Requirement
52
+ requirement: &id003 !ruby/object:Gem::Requirement
66
53
  none: false
67
- requirements:
68
- - - ! '>='
69
- - !ruby/object:Gem::Version
70
- version: '0'
54
+ requirements:
55
+ - - ">="
56
+ - !ruby/object:Gem::Version
57
+ hash: 3
58
+ segments:
59
+ - 0
60
+ version: "0"
71
61
  type: :runtime
62
+ version_requirements: *id003
63
+ - !ruby/object:Gem::Dependency
64
+ name: activemodel
72
65
  prerelease: false
73
- version_requirements: !ruby/object:Gem::Requirement
66
+ requirement: &id004 !ruby/object:Gem::Requirement
74
67
  none: false
75
- requirements:
76
- - - ! '>='
77
- - !ruby/object:Gem::Version
78
- version: '0'
79
- - !ruby/object:Gem::Dependency
68
+ requirements:
69
+ - - ">="
70
+ - !ruby/object:Gem::Version
71
+ hash: 3
72
+ segments:
73
+ - 0
74
+ version: "0"
75
+ type: :runtime
76
+ version_requirements: *id004
77
+ - !ruby/object:Gem::Dependency
80
78
  name: rspec
81
- requirement: !ruby/object:Gem::Requirement
82
- none: false
83
- requirements:
84
- - - ! '>='
85
- - !ruby/object:Gem::Version
86
- version: '0'
87
- type: :development
88
79
  prerelease: false
89
- version_requirements: !ruby/object:Gem::Requirement
80
+ requirement: &id005 !ruby/object:Gem::Requirement
90
81
  none: false
91
- requirements:
92
- - - ! '>='
93
- - !ruby/object:Gem::Version
94
- version: '0'
95
- - !ruby/object:Gem::Dependency
96
- name: simplecov
97
- requirement: !ruby/object:Gem::Requirement
98
- none: false
99
- requirements:
100
- - - ! '>='
101
- - !ruby/object:Gem::Version
102
- version: '0'
82
+ requirements:
83
+ - - ">="
84
+ - !ruby/object:Gem::Version
85
+ hash: 3
86
+ segments:
87
+ - 0
88
+ version: "0"
103
89
  type: :development
90
+ version_requirements: *id005
91
+ - !ruby/object:Gem::Dependency
92
+ name: simplecov
104
93
  prerelease: false
105
- version_requirements: !ruby/object:Gem::Requirement
94
+ requirement: &id006 !ruby/object:Gem::Requirement
106
95
  none: false
107
- requirements:
108
- - - ! '>='
109
- - !ruby/object:Gem::Version
110
- version: '0'
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ hash: 3
100
+ segments:
101
+ - 0
102
+ version: "0"
103
+ type: :development
104
+ version_requirements: *id006
111
105
  description: Developed at On The Beach Ltd. Contact russell.dunphy@onthebeach.co.uk
112
- email:
106
+ email:
113
107
  - rssll@rsslldnphy.com
114
108
  - radek.molenda@gmail.com
115
109
  executables: []
110
+
116
111
  extensions: []
112
+
117
113
  extra_rdoc_files: []
118
- files:
114
+
115
+ files:
119
116
  - .gitignore
120
117
  - .rspec
121
118
  - .ruby-version
@@ -152,29 +149,38 @@ files:
152
149
  - spec/support/active_model_lint.rb
153
150
  homepage: http://github.com/onthebeach/id
154
151
  licenses: []
152
+
155
153
  post_install_message:
156
154
  rdoc_options: []
157
- require_paths:
155
+
156
+ require_paths:
158
157
  - lib
159
- required_ruby_version: !ruby/object:Gem::Requirement
158
+ required_ruby_version: !ruby/object:Gem::Requirement
160
159
  none: false
161
- requirements:
162
- - - ! '>='
163
- - !ruby/object:Gem::Version
164
- version: '0'
165
- required_rubygems_version: !ruby/object:Gem::Requirement
160
+ requirements:
161
+ - - ">="
162
+ - !ruby/object:Gem::Version
163
+ hash: 3
164
+ segments:
165
+ - 0
166
+ version: "0"
167
+ required_rubygems_version: !ruby/object:Gem::Requirement
166
168
  none: false
167
- requirements:
168
- - - ! '>='
169
- - !ruby/object:Gem::Version
170
- version: '0'
169
+ requirements:
170
+ - - ">="
171
+ - !ruby/object:Gem::Version
172
+ hash: 3
173
+ segments:
174
+ - 0
175
+ version: "0"
171
176
  requirements: []
177
+
172
178
  rubyforge_project:
173
179
  rubygems_version: 1.8.25
174
180
  signing_key:
175
181
  specification_version: 3
176
182
  summary: Simple models based on hashes
177
- test_files:
183
+ test_files:
178
184
  - spec/lib/id/model/association_spec.rb
179
185
  - spec/lib/id/model/field_spec.rb
180
186
  - spec/lib/id/model/form_spec.rb
@@ -184,4 +190,3 @@ test_files:
184
190
  - spec/lib/mike_spec.rb
185
191
  - spec/spec_helper.rb
186
192
  - spec/support/active_model_lint.rb
187
- has_rdoc: