Skip to content

Commit

Permalink
Simplified code
Browse files Browse the repository at this point in the history
  • Loading branch information
ankane committed Oct 26, 2024
1 parent a74eaa9 commit 850680d
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions lib/lockbox/model.rb
Original file line number Diff line number Diff line change
Expand Up @@ -428,16 +428,14 @@ def reload
else
attribute name, :string
end
else
elsif attributes_to_define_after_schema_loads[name.to_s].first.is_a?(Proc)
# hack for Active Record 6.1+ to set string type after serialize
# otherwise, type gets set to ActiveModel::Type::Value
# which always returns false for changed_in_place?
# earlier versions of Active Record take the previous code path
if attributes_to_define_after_schema_loads[name.to_s].first.is_a?(Proc)
attribute_type = attributes_to_define_after_schema_loads[name.to_s].first.call(nil)
if attribute_type.is_a?(ActiveRecord::Type::Serialized) && attribute_type.subtype.nil?
attribute name, ActiveRecord::Type::Serialized.new(ActiveRecord::Type::String.new, attribute_type.coder)
end
attribute_type = attributes_to_define_after_schema_loads[name.to_s].first.call(nil)
if attribute_type.is_a?(ActiveRecord::Type::Serialized) && attribute_type.subtype.nil?
attribute name, ActiveRecord::Type::Serialized.new(ActiveRecord::Type::String.new, attribute_type.coder)
end
end

Expand Down

0 comments on commit 850680d

Please sign in to comment.