instance method build_column_serializer

Ruby on Rails 8.1.2

Since v7.1.6 Private

Available in: v7.1.6 v7.2.3 v8.0.4 v8.1.2

Signature

build_column_serializer(attr_name, coder, type, yaml = nil)

No documentation comment.

Parameters

attr_name req
coder req
type req
yaml opt = nil
Source
# File activerecord/lib/active_record/attribute_methods/serialization.rb, line 218
          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.

            if coder == ::JSON || coder == Coders::JSON
              coder = Coders::JSON.new
            end

            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 218 · View on GitHub · Improve this page · Find usages on GitHub

Defined in ActiveRecord::AttributeMethods::Serialization::ClassMethods

Type at least 2 characters to search.

↑↓ navigate · open · esc close