Class: SavonHelper::DatetimeMapping
- Inherits:
-
TypeMapping
- Object
- TypeMapping
- SavonHelper::DatetimeMapping
- Defined in:
- lib/savon_helper/type_mappings.rb
Overview
DatetimeMapping maps Savon data to Ruby DateTimes.
Instance Attribute Summary
Attributes inherited from TypeMapping
Converting collapse
-
#to_native(data, interface) ⇒ DateTime
Convert from Savon data to Ruby datetime.
-
#to_savon(value) ⇒ String
Convert from Ruby DateTime type to Savon data.
Instance Method Summary collapse
- #default_value ⇒ Object abstract
-
#object_klass ⇒ DateTime
Return the class represented by the mapping.
-
#type_string ⇒ String
Return the class description represented by the mapping.
Methods inherited from TypeMapping
Constructor Details
This class inherits a constructor from SavonHelper::TypeMapping
Instance Method Details
#default_value ⇒ Object
This method is abstract.
Return the default value the mapping.
275 276 277 |
# File 'lib/savon_helper/type_mappings.rb', line 275 def default_value DateTime.now() end |
#object_klass ⇒ DateTime
Return the class represented by the mapping.
263 264 265 |
# File 'lib/savon_helper/type_mappings.rb', line 263 def object_klass DateTime end |
#to_native(data, interface) ⇒ DateTime
Convert from Savon data to Ruby datetime
248 249 250 |
# File 'lib/savon_helper/type_mappings.rb', line 248 def to_native(data, interface) DateTime.parse(data.to_s) end |
#to_savon(value) ⇒ String
Convert from Ruby DateTime type to Savon data
255 256 257 |
# File 'lib/savon_helper/type_mappings.rb', line 255 def to_savon(value) value.to_datetime.to_s end |
#type_string ⇒ String
Return the class description represented by the mapping.
269 270 271 |
# File 'lib/savon_helper/type_mappings.rb', line 269 def type_string "datetime" end |