serializer 0.0.1 → 0.0.2
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.
- data/lib/serializer.rb +9 -4
- data/lib/serializer/version.rb +1 -1
- metadata +1 -1
data/lib/serializer.rb
CHANGED
@@ -28,18 +28,23 @@ module Serializer
|
|
28
28
|
initializer.each do |method, options|
|
29
29
|
|
30
30
|
define_method "#{method}" do
|
31
|
-
|
32
|
-
|
31
|
+
hash = send(name)
|
32
|
+
result = hash[method.intern] if hash
|
33
|
+
return options[:default] if hash.nil? or result.nil?
|
33
34
|
return result
|
34
35
|
end
|
35
36
|
|
36
37
|
define_method "#{method}?" do
|
37
|
-
|
38
|
-
|
38
|
+
hash = send(name)
|
39
|
+
result = hash[method.intern]
|
40
|
+
return options[:default] if hash.nil? or result.nil?
|
39
41
|
return result
|
40
42
|
end
|
41
43
|
|
42
44
|
define_method "#{method}=" do |value|
|
45
|
+
send("#{name}=", {}) unless send(name)
|
46
|
+
hash = send(name)
|
47
|
+
|
43
48
|
if options[:type] and value
|
44
49
|
case options[:type].intern
|
45
50
|
when :float then value = value.to_f if value.respond_to? :to_f
|
data/lib/serializer/version.rb
CHANGED