hash_dealer 1.5.0 → 1.5.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "hash_dealer"
8
- s.version = "1.5.0"
8
+ s.version = "1.5.1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Dan Langevin"]
@@ -69,14 +69,19 @@ class HashDealer
69
69
  protected
70
70
 
71
71
  # method missing
72
- def method_missing(meth, value = nil, opts = {}, &block)
72
+ def method_missing(meth, *args, &block)
73
73
 
74
- unless value.present? || block_given?
74
+ unless args.length > 0 || block_given?
75
75
  raise Exception.new(
76
76
  "Please provide either a String or a block to #{meth}"
77
77
  )
78
78
  end
79
-
79
+ # a second arg is the options hash
80
+ opts = args[1] || {}
81
+
82
+ # the value is the first arg
83
+ value = args[0]
84
+
80
85
  if opts[:optional]
81
86
  @optional_attributes << meth.to_sym
82
87
  end
@@ -220,6 +220,19 @@ describe HashDealer do
220
220
  data[:child_value].should eql("x")
221
221
 
222
222
  end
223
+
224
+ context "nil and false values" do
225
+ it "should allow nil and false values" do
226
+ HashDealer.define(:with_nil_and_false_values) do
227
+ nil_value nil
228
+ false_value false
229
+ end
230
+ HashDealer.roll(:with_nil_and_false_values).should eql({
231
+ :nil_value => nil,
232
+ :false_value => false
233
+ })
234
+ end
235
+ end
223
236
 
224
237
  context "optional values" do
225
238
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hash_dealer
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.5.0
4
+ version: 1.5.1
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors: