class ActiveModel::Coercer
Public Class Methods
defined_coercions()
click to toggle source
# File lib/active_model/coercer.rb, line 14 def defined_coercions { integer: ActiveModel::Coercions::Types::Integer, float: ActiveModel::Coercions::Types::Float, symbol: ActiveModel::Coercions::Types::Symbol, time: ActiveModel::Coercions::Types::Time, date: ActiveModel::Coercions::Types::Date, datetime: ActiveModel::Coercions::Types::DateTime, boolean: ActiveModel::Coercions::Types::Boolean } end
new(type)
click to toggle source
# File lib/active_model/coercer.rb, line 5 def initialize(type) @coercion_type = self.class.defined_coercions.fetch(type) end
Public Instance Methods
cast(value)
click to toggle source
# File lib/active_model/coercer.rb, line 9 def cast(value) @coercion_type.new(value).to_value end