Module: Toy::Extensions::Boolean

Included in:
Boolean
Defined in:
lib/toy/extensions/boolean.rb

Constant Summary collapse

Mapping =
{
  true    => true,
  'true'  => true,
  'TRUE'  => true,
  'True'  => true,
  't'     => true,
  'T'     => true,
  '1'     => true,
  'on'    => true,
  'ON'    => true,
  1       => true,
  1.0     => true,
  false   => false,
  'false' => false,
  'FALSE' => false,
  'False' => false,
  'f'     => false,
  'F'     => false,
  '0'     => false,
  'off'   => false,
  'OFF'   => false,
  0       => false,
  0.0     => false,
  nil     => nil
}

Instance Method Summary collapse

Instance Method Details

#from_store(value) ⇒ Object



38
39
40
# File 'lib/toy/extensions/boolean.rb', line 38

def from_store(value, *)
  to_store(value)
end

#to_store(value) ⇒ Object



30
31
32
33
34
35
36
# File 'lib/toy/extensions/boolean.rb', line 30

def to_store(value, *)
  if value.is_a?(Boolean)
    value
  else
    Mapping[value]
  end
end