Class: MLS::Property::DateTime
- Inherits:
-
MLS::Property
- Object
- MLS::Property
- MLS::Property::DateTime
- Defined in:
- lib/mls/properties/datetime.rb
Constant Summary
Constants inherited from MLS::Property
Instance Attribute Summary
Attributes inherited from MLS::Property
#default, #instance_variable_name, #model, #name, #options, #reader_visibility, #writer_visibility
Instance Method Summary collapse
- #dump(value) ⇒ Object
-
#load(value) ⇒ Object
from_json.
Methods inherited from MLS::Property
demodulized_names, determine_class, #determine_visibility, find_class, inherited, #initialize, #set_default_value
Constructor Details
This class inherits a constructor from MLS::Property
Instance Method Details
#dump(value) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/mls/properties/datetime.rb', line 15 def dump(value) if value.is_a?(::DateTime) || value.is_a?(::Time) || value.is_a?(::Date) value.iso8601 elsif value.nil? nil else raise 'unsupported date type' end end |
#load(value) ⇒ Object
from_json
3 4 5 6 7 8 9 10 11 12 13 |
# File 'lib/mls/properties/datetime.rb', line 3 def load(value) # from_json if value.is_a?(::String) ::DateTime.iso8601(value) elsif value.nil? || value.is_a?(::DateTime) value elsif value.is_a?(::Time) || value.is_a?(::Date) value.to_datetime else raise 'unsupported date type' end end |