hashstructor 1.0.2 → 1.0.3
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.
- checksums.yaml +4 -4
- data/lib/hashstructor/member.rb +18 -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: 620346f223f8ef18b1f9442286fb77640d486a58
|
4
|
+
data.tar.gz: 12a8b05f4dead8cf6c4a4b9a286975e08dcd368b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e2f79fcb466071cd46d3ae82dca1f27035fd14403f7c5488148429bc858bb10fa1621feb0a45d5a2807ee2dae3b89db993d33671455fdefdadb841746b197509
|
7
|
+
data.tar.gz: ae4186ea0b7b24f5a3f180e5c5c3ffdd220f1692dac456724e7f03e6444045cbec2020ebef649d8f9e49bebef68a20deaaf883872e5d210b1abef8b99851b19f
|
data/lib/hashstructor/member.rb
CHANGED
@@ -22,6 +22,22 @@ module Hashstructor
|
|
22
22
|
# @return [Symbol] the type of the member; see {VALID_MEMBER_TYPES}.
|
23
23
|
attr_reader :member_type
|
24
24
|
|
25
|
+
# The procedure used in {VALID_VALUE_TYPES} for both `TrueClass` and
|
26
|
+
# `FalseClass`.
|
27
|
+
BOOL_PROC = Proc.new do |v|
|
28
|
+
v = v.downcase
|
29
|
+
|
30
|
+
case v.downcase
|
31
|
+
when "true", "t", "on", "yes"
|
32
|
+
true
|
33
|
+
when "false", "f", "off", "no"
|
34
|
+
false
|
35
|
+
else
|
36
|
+
raise HashstructorError, "unknown value when parsing boolean: #{v}"
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
|
25
41
|
# A hash of Class => Proc converters for value types. Any value type
|
26
42
|
# in this list, as well as any class that includes or prepends
|
27
43
|
# `Hashstructor`, is valid for {#value_type}. This is _intentionally_
|
@@ -40,12 +56,8 @@ module Hashstructor
|
|
40
56
|
Float => Proc.new do |v|
|
41
57
|
Float(v.to_s)
|
42
58
|
end,
|
43
|
-
TrueClass =>
|
44
|
-
|
45
|
-
end,
|
46
|
-
FalseClass => Proc.new do |v|
|
47
|
-
!!v
|
48
|
-
end,
|
59
|
+
TrueClass => BOOL_PROC,
|
60
|
+
FalseClass => BOOL_PROC,
|
49
61
|
}
|
50
62
|
# Determines the class that Hashstructor should attempt to coerce a
|
51
63
|
# given value into. For example, `Fixnum` will attempt to coerce a
|
data/lib/hashstructor/version.rb
CHANGED