instance method
cast_value
Ruby on Rails edge
Since v7.1.6 Private — implementation detail, not part of the public APISignature
cast_value(value)
No documentation comment.
Parameters
-
valuereq
Source
# File activemodel/lib/active_model/type/integer.rb, line 118
def cast_value(value)
case value
when ::Integer
value
when ::String
max_bytesize = max_cast_bytesize
str = value.bytesize > max_bytesize ? value.byteslice(0, max_bytesize) : value
str.to_i rescue nil
else
value.to_i rescue nil
end
end
Defined in activemodel/lib/active_model/type/integer.rb line 118
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveModel::Type::Integer