packed-model 0.1.5 → 0.1.6
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/packed_model/base.rb +6 -0
- data/packed-model.gemspec +1 -1
- data/spec/packed_model/base_spec.rb +9 -4
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.6
|
data/lib/packed_model/base.rb
CHANGED
@@ -203,6 +203,12 @@ module PackedModel
|
|
203
203
|
values.each do |k, v|
|
204
204
|
send("#{k}=", v) if self.class.field_options(k)
|
205
205
|
end
|
206
|
+
fields.each do |options|
|
207
|
+
next unless options[:fields]
|
208
|
+
options[:fields].each do |field|
|
209
|
+
send("#{field}=", values[field]) if values.has_key?(field)
|
210
|
+
end
|
211
|
+
end
|
206
212
|
# set default values
|
207
213
|
fields.each_with_index do |field, idx|
|
208
214
|
@values[idx] ||= self.class.default_values[idx]
|
data/packed-model.gemspec
CHANGED
@@ -229,10 +229,10 @@ describe PackedModel::Base do
|
|
229
229
|
it "should be able to set and unset individual flags" do
|
230
230
|
m = TestBitVectorPackedModel.new
|
231
231
|
m.bit1 = true
|
232
|
-
m.bit7 =
|
233
|
-
m.bit10 = true
|
234
|
-
m.bit17 =
|
235
|
-
m.bit20 =
|
232
|
+
m.bit7 = 1
|
233
|
+
m.bit10 = 'true'
|
234
|
+
m.bit17 = 'on'
|
235
|
+
m.bit20 = 'yes'
|
236
236
|
|
237
237
|
m = TestBitVectorPackedModel.new m.pack
|
238
238
|
m.bit1.should be_true
|
@@ -274,5 +274,10 @@ describe PackedModel::Base do
|
|
274
274
|
m.bit1 ||= false
|
275
275
|
m.bit1.should be_false
|
276
276
|
end
|
277
|
+
|
278
|
+
it "should be able to set bits from the initializer" do
|
279
|
+
m = TestBitVectorPackedModel.new :bit2 => true
|
280
|
+
m.bit2.should be_true
|
281
|
+
end
|
277
282
|
end
|
278
283
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: packed-model
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.6
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -83,7 +83,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
83
83
|
version: '0'
|
84
84
|
segments:
|
85
85
|
- 0
|
86
|
-
hash:
|
86
|
+
hash: 2188948874657673809
|
87
87
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
88
|
none: false
|
89
89
|
requirements:
|