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.
Instance Attribute Summary
Attributes inherited from TypeMapping
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
Constructor Details
#initialize(enum, name = '', description = '') ⇒ EnumMapping
A new instance of EnumMapping with description and enum hash enum.
288 289 290 291 |
# File 'lib/savon_helper/type_mappings.rb', line 288 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.
319 320 321 |
# File 'lib/savon_helper/type_mappings.rb', line 319 def default_value :none end |
#to_native(data, interface) ⇒ Symbol?
Convert from Savon enum-String to Ruby Symbol
298 299 300 |
# File 'lib/savon_helper/type_mappings.rb', line 298 def to_native(data, interface) @enum[data] end |
#to_savon(value) ⇒ String
Convert from Ruby DateTime Symbol to Savon enum-String
305 306 307 |
# File 'lib/savon_helper/type_mappings.rb', line 305 def to_savon(value) @enum.key(value) end |
#type_string ⇒ String
Return the class description represented by the mapping.
313 314 315 |
# File 'lib/savon_helper/type_mappings.rb', line 313 def type_string "enum<#{@enum.values.join(', ')}>" end |