packed-model 0.1.7 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/VERSION +1 -1
- data/lib/packed_model/base.rb +10 -0
- data/packed-model.gemspec +1 -1
- data/spec/packed_model/base_spec.rb +17 -0
- metadata +2 -2
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.1.
|
1
|
+
0.1.8
|
data/lib/packed_model/base.rb
CHANGED
@@ -115,6 +115,16 @@ module PackedModel
|
|
115
115
|
end
|
116
116
|
METHOD
|
117
117
|
|
118
|
+
if options.has_key?(:nil)
|
119
|
+
method_src << <<-METHOD
|
120
|
+
def #{name}_with_nil_check
|
121
|
+
#{name}_without_nil_check == #{options[:nil].inspect} ? nil : #{name}_without_nil_check
|
122
|
+
end
|
123
|
+
alias #{name}_without_nil_check #{name}
|
124
|
+
alias #{name} #{name}_with_nil_check
|
125
|
+
METHOD
|
126
|
+
end
|
127
|
+
|
118
128
|
case options[:type]
|
119
129
|
when :string, :char
|
120
130
|
method_src << <<-METHOD
|
data/packed-model.gemspec
CHANGED
@@ -280,4 +280,21 @@ describe PackedModel::Base do
|
|
280
280
|
m.bit2.should be_true
|
281
281
|
end
|
282
282
|
end
|
283
|
+
|
284
|
+
context "nil value" do
|
285
|
+
class TestNilValuePackedModel < PackedModel::Base
|
286
|
+
attribute :count, :type => :integer
|
287
|
+
attribute :application_id, :type => :integer, :nil => 0
|
288
|
+
end
|
289
|
+
|
290
|
+
it "should return nil if the value of the integer equals the nil value" do
|
291
|
+
m = TestNilValuePackedModel.new
|
292
|
+
m.count.should == 0
|
293
|
+
m.application_id.should be_nil
|
294
|
+
|
295
|
+
m = TestNilValuePackedModel.new :count => 5, :application_id => 1
|
296
|
+
m.count.should == 5
|
297
|
+
m.application_id.should == 1
|
298
|
+
end
|
299
|
+
end
|
283
300
|
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.8
|
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: 2279594938976666295
|
87
87
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
88
88
|
none: false
|
89
89
|
requirements:
|