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 +4 -4
- data/lib/hashstructor/instance_methods.rb +5 -2
- data/lib/hashstructor/member.rb +13 -6
- data/lib/hashstructor/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 17721f8a9d6290570bc704b98b9ac7c946c28783
|
4
|
+
data.tar.gz: 8620ad7296bc271d28c2b7e7b9cd08f75ab3b6e4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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]
|
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
|
data/lib/hashstructor/member.rb
CHANGED
@@ -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
|
-
|
29
|
-
|
30
|
-
case v.downcase
|
31
|
-
when "true", "t", "on", "yes"
|
28
|
+
case v
|
29
|
+
when true
|
32
30
|
true
|
33
|
-
when
|
31
|
+
when false
|
34
32
|
false
|
35
33
|
else
|
36
|
-
raise
|
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
|
|
data/lib/hashstructor/version.rb
CHANGED