Module: EasyType::Mungers::Boolean

Defined in:
lib/easy_type/mungers.rb

Overview

The Boolean munger, munges a specified value to a Boolean.

Instance Method Summary collapse

Instance Method Details

#unsafe_munge(value) ⇒ Object

rubocop: disable Lint/BooleanSymbol



64
65
66
67
68
69
70
71
72
# File 'lib/easy_type/mungers.rb', line 64

def unsafe_munge(value)
  if resource_api_available? && self.class.data_type
    super
  else
    return true if [true, 'true', :true, :yes, 'yes'].include?(value)
    return false if [false, 'false', :false, :no, 'no', :undef, nil].include?(value)
    fail "Invalid value found. #{value} is not a valid boolean."
  end
end