Module: ActiveModel::Type::SerializeCastValue
Do not use. This module is for internal use only.
Class Method Summary
::ActiveSupport::Concern - Extended
| class_methods | Define class methods from given block. |
| included | Evaluate given block in context of base class, so that you can write class macros here. |
| prepended | Evaluate given block in context of base class, so that you can write class macros here. |
| append_features, prepend_features | |
Instance Method Summary
Class Method Details
.included(klass)
[ GitHub ]# File 'activemodel/lib/active_model/type/serialize_cast_value.rb', line 21
def self.included(klass) klass.include DefaultImplementation unless klass.method_defined?(:serialize_cast_value) end
.serialize(type, value)
[ GitHub ]# File 'activemodel/lib/active_model/type/serialize_cast_value.rb', line 25
def self.serialize(type, value) # Using `type.equal?(type.itself_if_...)` is a performant way to also # ensure that `type` is not just a DelegateClass instance (e.g. # ActiveRecord::Type::Serialized) unintentionally delegating # SerializeCastValue methods. if type.equal?((type.itself_if_serialize_cast_value_compatible rescue nil)) type.serialize_cast_value(value) else type.serialize(value) end end
Instance Method Details
#initialize
[ GitHub ]# File 'activemodel/lib/active_model/type/serialize_cast_value.rb', line 41
def initialize(...) super self.class.serialize_cast_value_compatible? # eagerly compute end
#itself_if_serialize_cast_value_compatible
[ GitHub ]# File 'activemodel/lib/active_model/type/serialize_cast_value.rb', line 37
def itself_if_serialize_cast_value_compatible self if self.class.serialize_cast_value_compatible? end