Sha256: 1755fccb005136ac81e18921da78a43213b337df873cd70c2f987af863874e8e

Contents?: true

Size: 842 Bytes

Versions: 2

Compression:

Stored size: 842 Bytes

Contents

module Globalize
  module AttributeMethods
    module Serialization
      def serialize(attr_name, class_name_or_coder = Object, **options)
        super(attr_name, class_name_or_coder, **options)

        coder = if class_name_or_coder == ::JSON
                  ::ActiveRecord::Coders::JSON
                elsif [:load, :dump].all? { |x| class_name_or_coder.respond_to?(x) }
                  class_name_or_coder
                else
                  ::ActiveRecord::Coders::YAMLColumn.new(attr_name, class_name_or_coder)
                end

        self.globalize_serialized_attributes = globalize_serialized_attributes.dup
        self.globalize_serialized_attributes[attr_name] = coder
      end
    end
  end
end

ActiveRecord::AttributeMethods::Serialization::ClassMethods.send(:prepend, Globalize::AttributeMethods::Serialization)

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
globalize-6.3.0 lib/patches/active_record/rails6_1/serialization.rb
globalize-6.2.1 lib/patches/active_record/rails6_1/serialization.rb