rails_metadata 0.0.4 → 0.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/rails_metadata.rb +14 -1
- data/lib/rails_metadata/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: 0e901aa7424ebd6f4eb6d6f5854d0e9f9009422e
|
4
|
+
data.tar.gz: 6004562b7a90e7e2ee1de650a27168cd0ec6c8d5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e8aa0825cba531037b228ad0fd77e8402c17245247daa44e8b859a178d976288b63adce02b590280aa491979d6e46c40fec321826091b4778c3b1138d4d142ad
|
7
|
+
data.tar.gz: 93560759cf5d786b65528adf6fef4e39382797c5d18cd615a106112adec344345a18295b250c2df8f198ba8ef9587abf63bbdaa164021676ffdea627b554f7fe
|
data/lib/rails_metadata.rb
CHANGED
@@ -13,7 +13,20 @@ module RailsMetadata
|
|
13
13
|
end
|
14
14
|
typecast = case type
|
15
15
|
when nil then val
|
16
|
-
when :boolean
|
16
|
+
when :boolean
|
17
|
+
lambda do |v|
|
18
|
+
if v.is_a(String)
|
19
|
+
if ["true", "1"].include?(v)
|
20
|
+
return true
|
21
|
+
elsif ["false", "0"].include?(v)
|
22
|
+
return false
|
23
|
+
else
|
24
|
+
return !v.empty?
|
25
|
+
end
|
26
|
+
else
|
27
|
+
return !!v
|
28
|
+
end
|
29
|
+
end
|
17
30
|
when :string then lambda { |v| v.to_s }
|
18
31
|
when :integer then lambda { |v| v.to_i }
|
19
32
|
when :float then lambda { |v| v.to_f }
|