Skip to content

Commit

Permalink
Update serialization.rb
Browse files Browse the repository at this point in the history
  • Loading branch information
jwoodrow authored Jan 5, 2024
1 parent 3859217 commit d63e60b
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/patches/active_record/rails7_1/serialization.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@ module Globalize
module AttributeMethods
module Serialization
def serialize(attr_name, class_name_or_coder = Object, **options)
if class_name_or_coder == ::JSON || [:load, :dump].all? { |x| class_name_or_coder.respond_to?(x) }
options = options.merge(coder: class_name_or_coder, type: Object)
else
options = options.merge(coder: default_column_serializer, type: class_name_or_coder)
if options[:coder].blank?
if class_name_or_coder == ::JSON || [:load, :dump].all? { |x| class_name_or_coder.respond_to?(x) }
options = options.merge(coder: class_name_or_coder, type: Object)
else
options = options.merge(coder: default_column_serializer, type: class_name_or_coder)
end
end

super(attr_name, **options)
Expand All @@ -19,4 +21,4 @@ def serialize(attr_name, class_name_or_coder = Object, **options)
end
end

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

0 comments on commit d63e60b

Please sign in to comment.