Class: SavonHelper::BooleanMapping

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

Overview

BooleanMapping maps Savon data to Ruby Booleans.

Instance Attribute Summary

Attributes inherited from TypeMapping

#description, #name

Converting collapse

Instance Method Summary collapse

Methods inherited from TypeMapping

#initialize

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:



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

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



80
81
82
# File 'lib/savon_helper/type_mappings.rb', line 80

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)


64
65
66
# File 'lib/savon_helper/type_mappings.rb', line 64

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:



71
72
73
# File 'lib/savon_helper/type_mappings.rb', line 71

def to_savon(value)
  value.to_s
end

#type_stringString

Return the class description represented by the mapping.

Returns:



86
87
88
# File 'lib/savon_helper/type_mappings.rb', line 86

def type_string
  "bool"
end