method
build_column_serializer
v7.1.3.2 -
Show latest stable
- Class:
ActiveRecord::AttributeMethods::Serialization::ClassMethods
build_column_serializer(attr_name, coder, type, yaml = nil)private
No documentation available.
# File activerecord/lib/active_record/attribute_methods/serialization.rb, line 228
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