instance method
build_column_serializer
Ruby on Rails 8.0.4
Since v7.1.6 PrivateSignature
build_column_serializer(attr_name, coder, type, yaml = nil)
No documentation comment.
Parameters
-
attr_namereq -
coderreq -
typereq -
yamlopt = nil
Source
# File activerecord/lib/active_record/attribute_methods/serialization.rb, line 208
def build_column_serializer(attr_name, coder, type, yaml = nil)
# When ::JSON is used, force it to go through the Active Support JSON encoder
# to ensure special objects (e.g. Active Record models) are dumped correctly
# using the #as_json hook.
coder = Coders::JSON if coder == ::JSON
if coder == ::YAML || coder == Coders::YAMLColumn
Coders::YAMLColumn.new(attr_name, type, **(yaml || {}))
elsif coder.respond_to?(:new) && !coder.respond_to?(:load)
coder.new(attr_name, type)
elsif type && type != Object
Coders::ColumnSerializer.new(attr_name, coder, type)
else
coder
end
end
Defined in activerecord/lib/active_record/attribute_methods/serialization.rb line 208
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in ActiveRecord::AttributeMethods::Serialization::ClassMethods