Class: ActionSet::AttributeValue::BooleanAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/action_set/attribute_value.rb

Instance Method Summary collapse

Constructor Details

#initialize(raw, target) ⇒ BooleanAdapter

Returns a new instance of BooleanAdapter.



126
127
128
129
# File 'lib/action_set/attribute_value.rb', line 126

def initialize(raw, target)
  @raw = raw
  @target = target
end

Instance Method Details

#processObject



131
132
133
134
135
136
137
# File 'lib/action_set/attribute_value.rb', line 131

def process
  return if @raw.is_a? @target
  return unless @target.eql?(TrueClass) || @target.eql?(FalseClass)

  # ActiveModel::Type::Boolean is too expansive in its casting; will get false positives
  to_bool
end