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.
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
#description, #initialize, #warn_unparseable_data
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.
288 289 290 |
# File 'lib/savon_helper/type_mappings.rb', line 288 def default_value DateTime.now() end |
#object_klass ⇒ DateTime
Return the class represented by the mapping.
276 277 278 |
# File 'lib/savon_helper/type_mappings.rb', line 276 def object_klass DateTime end |
#to_native(data, interface) ⇒ DateTime
Convert from Savon data to Ruby datetime
261 262 263 |
# File 'lib/savon_helper/type_mappings.rb', line 261 def to_native(data, interface) DateTime.parse(data.to_s) end |
#to_savon(value) ⇒ String
Convert from Ruby DateTime type to Savon data
268 269 270 |
# File 'lib/savon_helper/type_mappings.rb', line 268 def to_savon(value) value.to_datetime.to_s end |
#type_string ⇒ String
Return the class description represented by the mapping.
282 283 284 |
# File 'lib/savon_helper/type_mappings.rb', line 282 def type_string "datetime" end |