Module: ActiveModel::Type::SerializeCastValue
- Extended by:
- ActiveSupport::Concern
- Included in:
- Value
- Defined in:
- lib/active_model/type/serialize_cast_value.rb
Overview
Defined Under Namespace
Modules: ClassMethods, DefaultImplementation
Class Method Summary
collapse
Instance Method Summary
collapse
Class Method Details
.included(klass) ⇒ Object
21
22
23
|
# File '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) ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/active_model/type/serialize_cast_value.rb', line 25
def self.serialize(type, value)
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 ⇒ Object
41
42
43
44
|
# File 'lib/active_model/type/serialize_cast_value.rb', line 41
def initialize(...)
super
self.class.serialize_cast_value_compatible? end
|
#itself_if_serialize_cast_value_compatible ⇒ Object
37
38
39
|
# File '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
|