Class: SavonHelper::BooleanMapping

Inherits:
TypeMapping show all
Defined in:
lib/savon_helper/type_mappings.rb

Overview

BooleanMapping maps Savon data to Ruby Booleans.

Converting collapse

Instance Method Summary collapse

Methods inherited from TypeMapping

#description, #initialize, #warn_unparseable_data

Constructor Details

This class inherits a constructor from SavonHelper::TypeMapping

Instance Method Details

#default_valueObject

This method is abstract.

Return the default value the mapping.

Returns:



105
106
107
# File 'lib/savon_helper/type_mappings.rb', line 105

def default_value
  false
end

#object_klassTrueClass

Return the class represented by the mapping.

Returns:

  • (TrueClass)

    Return TrueClass as Ruby as no common Boolan class



93
94
95
# File 'lib/savon_helper/type_mappings.rb', line 93

def object_klass
  TrueClass
end

#to_native(data, interface) ⇒ Boolean

Convert from Savon data to Ruby Boolean

Parameters:

  • data (Hash, Boolean, String)

    Source Savon data

Returns:

  • (Boolean)


77
78
79
# File 'lib/savon_helper/type_mappings.rb', line 77

def to_native(data, interface)
  data.to_s == "true"
end

#to_savon(value) ⇒ String

Convert from Ruby Boolean type to Savon data

Parameters:

  • value (Boolean)

    Source Ruby data

Returns:



84
85
86
# File 'lib/savon_helper/type_mappings.rb', line 84

def to_savon(value)
  value.to_s
end

#type_stringString

Return the class description represented by the mapping.

Returns:



99
100
101
# File 'lib/savon_helper/type_mappings.rb', line 99

def type_string
  "bool"
end