class Necromancer::BooleanConverters::IntegerToBooleanConverter

An object that converts an Integer to a Boolean

Public Instance Methods

call(value, options = {}) click to toggle source

Convert integer to boolean

@example

converter.call(1)  # => true

@example

converter.call(0)  # => false

@api public

# File lib/necromancer/converters/boolean.rb, line 52
def call(value, options = {})
  strict = options.fetch(:strict, config.strict)
  begin
    !value.zero?
  rescue
    strict ? fail_conversion_type(value) : value
  end
end