hashstructor 1.0.4 → 1.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: a1ad5bd4ed2435710e89dced0e861acb0f378033
4
- data.tar.gz: dfee1459fe7866400567e0458b814c6f87132624
3
+ metadata.gz: 17721f8a9d6290570bc704b98b9ac7c946c28783
4
+ data.tar.gz: 8620ad7296bc271d28c2b7e7b9cd08f75ab3b6e4
5
5
  SHA512:
6
- metadata.gz: 0d0c80cc0ac5d667c96683a6bf61cdf85c96899ddf275e84ab7d3261c93b3061dc901d3d8deedf46270f50f8de13c939e1eb40a441328139b1fab3684b14fc0e
7
- data.tar.gz: 2dd1ac46636fd0af6a01a5c2b3149ed65bcee98e531572d3b037b6103c50bd135f9dc86eac010f27a090268dc2167e4d7fe735f6aadb42f803dafffaaa14cd3f
6
+ metadata.gz: a4d0f4aade414dd0bcd7b3bb8c249b68050098274b6146c9b30df3b787e68b1a67ef3eee56579ccfd560543b7707cbf7c409332f648b0eade531ba68d7e47fa9
7
+ data.tar.gz: 0bacfbb30a8bf7a9404be306048287ba4cae1f23ce25d96c3a5b9fcc690cb4590f0ba40b52edf2debd4f8e5145ec75be8315b862237587bfa7403f4bfa881ea0
@@ -25,7 +25,7 @@ module Hashstructor
25
25
  # This could be done inline, but I'd rather loop twice and get this check
26
26
  # out of the way ahead of time because of the perf hit when dealing with
27
27
  # deeply nested structures.
28
- partitioned_members = members.partition { |m| hash[m.name] || hash[m.name.to_s] }
28
+ partitioned_members = members.partition { |m| !hash[m.name].nil? || !hash[m.name.to_s].nil? }
29
29
 
30
30
  existing_members = partitioned_members[0]
31
31
  missing_members = partitioned_members[1]
@@ -54,7 +54,10 @@ module Hashstructor
54
54
  end
55
55
 
56
56
  existing_members.each do |member|
57
- raw_value = hash[member.name] || hash[member.name.to_s]
57
+ raw_value = hash[member.name]
58
+ if raw_value.nil?
59
+ raw_value = hash[member.name.to_s]
60
+ end
58
61
  out_value = nil
59
62
 
60
63
  case member.member_type
@@ -25,15 +25,22 @@ module Hashstructor
25
25
  # The procedure used in {VALID_VALUE_TYPES} for both `TrueClass` and
26
26
  # `FalseClass`.
27
27
  BOOL_PROC = Proc.new do |v|
28
- v = v.downcase
29
-
30
- case v.downcase
31
- when "true", "t", "on", "yes"
28
+ case v
29
+ when true
32
30
  true
33
- when "false", "f", "off", "no"
31
+ when false
34
32
  false
35
33
  else
36
- raise HashstructorError, "unknown value when parsing boolean: #{v}"
34
+ raise "'#{v}' not stringable" unless v.respond_to?(:to_s) && !v.nil?
35
+ v = v.downcase
36
+ case v.downcase
37
+ when "true", "t", "on", "yes"
38
+ true
39
+ when "false", "f", "off", "no"
40
+ false
41
+ else
42
+ raise HashstructorError, "unknown value when parsing boolean: #{v}"
43
+ end
37
44
  end
38
45
  end
39
46
 
@@ -1,4 +1,4 @@
1
1
  module Hashstructor
2
2
  # The gem version. As one does.
3
- VERSION = "1.0.4"
3
+ VERSION = "1.0.5"
4
4
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: hashstructor
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ed Ropple