Module: ActiveModel::Form::FloatAttribute

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

Class Method Summary collapse

Class Method Details

.number?Boolean

Returns:

  • (Boolean)

60
61
62
# File 'lib/active_model/form/attributes.rb', line 60

def self.number?
  true
end

.parse(v) ⇒ Object


46
47
48
49
50
51
52
53
54
# File 'lib/active_model/form/attributes.rb', line 46

def self.parse(v)
  if v.present?
    Float(v)
  elsif ['', nil].include? v
    nil
  else
    raise "Couldn't parse float attribute value: '#{v}'"
  end
end

.typeObject


56
57
58
# File 'lib/active_model/form/attributes.rb', line 56

def self.type
  :float
end