Module: ActiveModel::Form::BooleanAttribute

Defined in:
lib/active_model/form/attributes.rb

Class Method Summary collapse

Class Method Details

.number?Boolean

Returns:

  • (Boolean)

20
21
22
# File 'lib/active_model/form/attributes.rb', line 20

def self.number?
  false
end

.parse(v) ⇒ Object


4
5
6
7
8
9
10
11
12
13
14
# File 'lib/active_model/form/attributes.rb', line 4

def self.parse(v)
  if ['1', 't', 'true', 'yes', true].include? v
    true
  elsif ['0', 'f', 'false', 'no', false].include? v
    false
  elsif ['', nil].include? v
    nil
  else
    raise "Couldn't parse boolean attribute value: '#{v}'"
  end
end

.typeObject


16
17
18
# File 'lib/active_model/form/attributes.rb', line 16

def self.type
  :boolean
end