Skip to content

Commit

Permalink
Move SerializePositionalToKwargsBridge to the plugin itself
Browse files Browse the repository at this point in the history
  • Loading branch information
jrafanie committed Oct 23, 2024
1 parent 157860a commit a3eb361
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 20 deletions.
3 changes: 2 additions & 1 deletion lib/manageiq/schema/engine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,13 @@ class Engine < ::Rails::Engine

ActiveSupport.on_load(:active_record) do
require_relative 'migrate_with_cleared_schema_cache'
require_relative 'serialize_positional_to_kwargs_bridge'
require_relative 'schema_statements'
require_relative 'command_recorder'
require_relative 'schema_dumper'

ActiveRecord::Migration.prepend(MigrateWithClearedSchemaCache)

ActiveRecord::AttributeMethods::Serialization::ClassMethods.send(:prepend, ManageIQ::Schema::SerializePositionalToKwargsBridge)
ActiveRecord::ConnectionAdapters::AbstractAdapter.include(SchemaStatements)
ActiveRecord::Migration::CommandRecorder.include(CommandRecorder)
ActiveRecord::ConnectionAdapters::SchemaDumper.prepend(SchemaDumper)
Expand Down
19 changes: 19 additions & 0 deletions lib/manageiq/schema/serialize_positional_to_kwargs_bridge.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module ManageIQ
module Schema
module SerializePositionalToKwargsBridge
def serialize(*args, **options)
return super if Rails.version >= "7.1"

# For rails 7.0.x, convert 7.1+ kwargs for coder/type into the positional argument
# class_name_or_coder
if options[:coder]
args << options.delete(:coder)
elsif options[:type]
args << options.delete(:type)
end

super(*args, **options)
end
end
end
end

This file was deleted.

0 comments on commit a3eb361

Please sign in to comment.