lib/necromancer/converters/boolean.rb in necromancer-0.2.0 vs lib/necromancer/converters/boolean.rb in necromancer-0.3.0
- old
+ new
@@ -25,11 +25,11 @@
# other values coerced to false are:
# 0, f, F, FALSE, false, False, n, N, NO, no, No, off, OFF
#
# @api public
def call(value, options = {})
- strict = options.fetch(:strict, false)
+ strict = options.fetch(:strict, config.strict)
case value.to_s
when TRUE_MATCHER then true
when FALSE_MATCHER then false
else strict ? fail_conversion_type(value) : value
end
@@ -46,15 +46,15 @@
# @example
# converter.call(0) # => false
#
# @api public
def call(value, options = {})
- strict = options.fetch(:strict, false)
+ strict = options.fetch(:strict, config.strict)
begin
!value.zero?
rescue
- strict ? fail_conversion_type(value) : value
+ strict ? fail_conversion_type(value) : value
end
end
end
# An object that converts a Boolean to an Integer
@@ -67,10 +67,10 @@
# @example
# converter.call(false) # => 0
#
# @api public
def call(value, options = {})
- strict = options.fetch(:strict, false)
+ strict = options.fetch(:strict, config.strict)
if ['TrueClass', 'FalseClass'].include?(value.class.name)
value ? 1 : 0
else
strict ? fail_conversion_type(value) : value
end