Class: Poncho::Params::IntegerParam
Instance Attribute Summary
#name, #options
Instance Method Summary
collapse
#initialize, type, #type
Constructor Details
This class inherits a constructor from Poncho::Param
Instance Method Details
#convert(value) ⇒ Object
10
11
12
13
14
|
# File 'lib/poncho/params/integer.rb', line 10
def convert(value)
Integer(value)
rescue TypeError, ArgumentError
nil
end
|
#validate_each(record, attribute, value) ⇒ Object
4
5
6
7
8
|
# File 'lib/poncho/params/integer.rb', line 4
def validate_each(record, attribute, value)
unless convert(value).is_a?(Integer)
record.errors.add(attribute, :invalid_integer, options.merge(:value => value))
end
end
|