packed-model 0.1.7 → 0.1.8

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.1.7
1
+ 0.1.8
@@ -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
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "packed-model"
8
- s.version = "0.1.7"
8
+ s.version = "0.1.8"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Doug Youch"]
@@ -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.7
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: 781577043543051578
86
+ hash: 2279594938976666295
87
87
  required_rubygems_version: !ruby/object:Gem::Requirement
88
88
  none: false
89
89
  requirements: