Class: SavonHelper::EnumMapping
- Inherits:
-
TypeMapping
- Object
- TypeMapping
- SavonHelper::EnumMapping
- Defined in:
- lib/savon_helper/type_mappings.rb
Overview
EnumMapping maps Savon integers to Ruby symbols.
Converting collapse
-
#to_native(data, interface) ⇒ Symbol?
Convert from Savon enum-String to Ruby Symbol.
-
#to_savon(value) ⇒ String
Convert from Ruby DateTime Symbol to Savon enum-String.
Instance Method Summary collapse
- #default_value ⇒ Object abstract
-
#initialize(enum, name = '', description = '') ⇒ EnumMapping
constructor
A new instance of EnumMapping with description and enum hash enum.
-
#type_string ⇒ String
Return the class description represented by the mapping.
Methods inherited from TypeMapping
#description, #object_klass, #warn_unparseable_data
Constructor Details
#initialize(enum, name = '', description = '') ⇒ EnumMapping
A new instance of EnumMapping with description and enum hash enum.
301 302 303 304 |
# File 'lib/savon_helper/type_mappings.rb', line 301 def initialize(enum, name='', description='') super(name, description) @enum = enum end |
Instance Method Details
#default_value ⇒ Object
This method is abstract.
Return the default value the mapping.
332 333 334 |
# File 'lib/savon_helper/type_mappings.rb', line 332 def default_value :none end |
#to_native(data, interface) ⇒ Symbol?
Convert from Savon enum-String to Ruby Symbol
311 312 313 |
# File 'lib/savon_helper/type_mappings.rb', line 311 def to_native(data, interface) @enum[data] end |
#to_savon(value) ⇒ String
Convert from Ruby DateTime Symbol to Savon enum-String
318 319 320 |
# File 'lib/savon_helper/type_mappings.rb', line 318 def to_savon(value) @enum.key(value) end |
#type_string ⇒ String
Return the class description represented by the mapping.
326 327 328 |
# File 'lib/savon_helper/type_mappings.rb', line 326 def type_string "enum<#{@enum.values.join(', ')}>" end |