lib/conglomerate/serializer.rb in conglomerate-0.6.0 vs lib/conglomerate/serializer.rb in conglomerate-0.7.0
- old
+ new
@@ -50,10 +50,11 @@
type = datum.fetch(:type, :value)
prompt = datum.fetch(:prompt, nil)
value = sanitize_value(
object, :name => name, :type => type, :default_value => default_value
)
+ value = format_value(value)
{"name" => name.to_s, type.to_s => value}.tap do |d|
d["prompt"] = prompt if build_template && prompt
end
end
@@ -183,9 +184,20 @@
default_value
end
end
else
object.send(name)
+ end
+ end
+
+ def format_value(value)
+ case value
+ when DateTime, Time
+ value.iso8601.sub(/\+00:00$/, "Z")
+ when Date
+ value.strftime("%Y-%m-%d")
+ else
+ value
end
end
def blank?(value)
if value.is_a?(String)