bound 0.0.8 → 0.0.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/bound.rb +5 -1
- data/lib/bound/version.rb +1 -1
- data/spec/bound_spec.rb +27 -3
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 46590308f9cc175507cdd528e744b43d72013d82
|
4
|
+
data.tar.gz: b98915c9a3be4b1a1fe2895862ae4987c83c2fcf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 1d58eb39f202864c80d0e0edf7b32ba15b1d45cdb7c3ca6f61a2f880b4b21890677fc21e98b72edfedd1ba8ff703690b252374dfd7ef891f8d2350bc0f21358b
|
7
|
+
data.tar.gz: f934f47ce58bad2dd8cddea11877fba384a24112e152bab5b447788707ee66d9d8efb64b6bcb9a2c637cc59f8d8c349e8c07def4bb4bb68d7cd3095a6fb1f9b8
|
data/lib/bound.rb
CHANGED
@@ -58,7 +58,7 @@ class Bound
|
|
58
58
|
self.nested_attributes += attributes
|
59
59
|
self.attributes += attributes
|
60
60
|
attr_reader *attributes
|
61
|
-
|
61
|
+
|
62
62
|
attributes.each do |attribute|
|
63
63
|
define_method :"#{attribute}=" do |initial_values|
|
64
64
|
nested_target = nested_attributes[attribute]
|
@@ -79,6 +79,10 @@ class Bound
|
|
79
79
|
validate!
|
80
80
|
seed
|
81
81
|
end
|
82
|
+
|
83
|
+
def __attributes__
|
84
|
+
self.class.attributes + self.class.optional_attributes
|
85
|
+
end
|
82
86
|
|
83
87
|
def method_missing(meth, *args, &blk)
|
84
88
|
attribute = meth.to_s.gsub(/=$/, '')
|
data/lib/bound/version.rb
CHANGED
data/spec/bound_spec.rb
CHANGED
@@ -55,6 +55,14 @@ describe Bound do
|
|
55
55
|
assert_match(/unknown.+gender/i, exception.message)
|
56
56
|
end
|
57
57
|
|
58
|
+
it 'exposes an attributes method' do
|
59
|
+
user = User.build(hash)
|
60
|
+
|
61
|
+
assert_equal 2, user.__attributes__.size
|
62
|
+
assert_includes user.__attributes__, :name
|
63
|
+
assert_includes user.__attributes__, :age
|
64
|
+
end
|
65
|
+
|
58
66
|
describe 'wrong initialization' do
|
59
67
|
it 'fails if new is not called with symbols' do
|
60
68
|
assert_raises ArgumentError do
|
@@ -111,6 +119,14 @@ describe Bound do
|
|
111
119
|
UserWithoutAge.build(subject)
|
112
120
|
end
|
113
121
|
end
|
122
|
+
|
123
|
+
it 'are also included in attributes' do
|
124
|
+
user = UserWithoutAge.build(hash)
|
125
|
+
|
126
|
+
assert_equal 2, user.__attributes__.size
|
127
|
+
assert_includes user.__attributes__, :name
|
128
|
+
assert_includes user.__attributes__, :age
|
129
|
+
end
|
114
130
|
end
|
115
131
|
|
116
132
|
describe 'no attributes' do
|
@@ -149,12 +165,12 @@ describe Bound do
|
|
149
165
|
BloggingUser = Bound.new(:name).nested(:posts => [Post])
|
150
166
|
let(:hash) do
|
151
167
|
{
|
152
|
-
:name => 'Steve',
|
168
|
+
:name => 'Steve',
|
153
169
|
:posts => [
|
154
170
|
{:title => 'It is christmas'},
|
155
171
|
{:title => 'NOT'}
|
156
172
|
]
|
157
|
-
}
|
173
|
+
}
|
158
174
|
end
|
159
175
|
|
160
176
|
it 'works with array of nested attributes' do
|
@@ -179,6 +195,14 @@ describe Bound do
|
|
179
195
|
end
|
180
196
|
|
181
197
|
end
|
198
|
+
|
199
|
+
it 'are also included in attributes' do
|
200
|
+
user = BloggingUser.build(hash)
|
201
|
+
|
202
|
+
assert_equal 2, user.__attributes__.size
|
203
|
+
assert_includes user.__attributes__, :name
|
204
|
+
assert_includes user.__attributes__, :posts
|
205
|
+
end
|
182
206
|
end
|
183
207
|
|
184
208
|
describe 'allows optional as constructor' do
|
@@ -198,4 +222,4 @@ describe Bound do
|
|
198
222
|
assert_equal "VW", Car.new(:producer => {:name => 'VW'}).producer.name
|
199
223
|
end
|
200
224
|
end
|
201
|
-
end
|
225
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: bound
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jakob Holderbaum
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-09-
|
12
|
+
date: 2013-09-25 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bundler
|
@@ -92,7 +92,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
92
92
|
version: '0'
|
93
93
|
requirements: []
|
94
94
|
rubyforge_project:
|
95
|
-
rubygems_version: 2.0.
|
95
|
+
rubygems_version: 2.0.0
|
96
96
|
signing_key:
|
97
97
|
specification_version: 4
|
98
98
|
summary: Implements a nice helper for fast boundary definitions
|