Class: Necromancer::BooleanConverters::BooleanToIntegerConverter
- Inherits:
-
Converter
- Object
- Converter
- Necromancer::BooleanConverters::BooleanToIntegerConverter
- Defined in:
- lib/necromancer/converters/boolean.rb
Overview
An object that converts a Boolean to an Integer
Instance Attribute Summary
Attributes inherited from Converter
Instance Method Summary collapse
-
#call(value, options = {}) ⇒ Object
Convert boolean to integer.
Methods inherited from Converter
create, #fail_conversion_type, #initialize
Constructor Details
This class inherits a constructor from Necromancer::Converter
Instance Method Details
#call(value, options = {}) ⇒ Object
Convert boolean to integer
74 75 76 77 78 79 80 81 |
# File 'lib/necromancer/converters/boolean.rb', line 74 def call(value, = {}) strict = .fetch(:strict, config.strict) if ['TrueClass', 'FalseClass'].include?(value.class.name) value ? 1 : 0 else strict ? fail_conversion_type(value) : value end end |