Class: Extant::Coercers::Boolean

Inherits:
Base
  • Object
show all
Defined in:
lib/extant/coercers/boolean.rb

Constant Summary

Constants inherited from Base

Extant::Coercers::Base::UncoercedValue

Instance Method Summary collapse

Methods inherited from Base

#coerced?, coercer_name, #initialize

Constructor Details

This class inherits a constructor from Extant::Coercers::Base

Instance Method Details

#coerceObject



3
4
5
6
7
8
9
10
11
12
13
# File 'lib/extant/coercers/boolean.rb', line 3

def coerce
  if [true, "true", 1].include?(value)
    self.coerced = true
    return true
  elsif [false, "false", 0].include?(value)
    self.coerced = true
    return false
  end

  Extant::UncoercedValue
end