Module: ActiveModel::Form::IntegerAttribute

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

Class Method Summary collapse

Class Method Details

.number?Boolean

Returns:

  • (Boolean)

40
41
42
# File 'lib/active_model/form/attributes.rb', line 40

def self.number?
  true
end

.parse(v) ⇒ Object


26
27
28
29
30
31
32
33
34
# File 'lib/active_model/form/attributes.rb', line 26

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

.typeObject


36
37
38
# File 'lib/active_model/form/attributes.rb', line 36

def self.type
  :integer
end