module ActiveRecord::AttributeMethods::Serialization::ClassMethods
def build_column_serializer(attr_name, coder, type, yaml = nil)
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