From 3c8fc7feb83cd02c4f77f2a9f5b56eda4faf9f54 Mon Sep 17 00:00:00 2001 From: Dalton Pinto Date: Wed, 24 Feb 2021 20:02:51 +0100 Subject: [PATCH] [Fix #722] Remove alias_method_chain, use Module#prepend instead (#764) --- CHANGELOG.md | 2 ++ lib/chewy/railtie.rb | 20 ++------------------ 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7c4b0324f..76e4266a8 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,8 @@ ### Bugs Fixed + * [#722](https://github.com/toptal/chewy/issues/722): Remove alias_method_chain, use Module#prepend instead ([@dalthon][]) + ## 7.0.0 (2021-02-22) ### New Features diff --git a/lib/chewy/railtie.rb b/lib/chewy/railtie.rb index eee33adee..5d1c48104 100644 --- a/lib/chewy/railtie.rb +++ b/lib/chewy/railtie.rb @@ -22,17 +22,6 @@ def call(env) end module MigrationStrategy - extend ActiveSupport::Concern - included do - alias_method_chain :migrate, :chewy - end - - def migrate_with_chewy(*args) - Chewy.strategy(:bypass) { migrate_without_chewy(*args) } - end - end - - module Rails5MigrationStrategy def migrate(*args) Chewy.strategy(:bypass) { super } end @@ -57,13 +46,8 @@ def migrate(*args) initializer 'chewy.migration_strategy' do ActiveSupport.on_load(:active_record) do - if Rails::VERSION::MAJOR >= 5 - ActiveRecord::Migration.prepend(Rails5MigrationStrategy) - ActiveRecord::Migrator.prepend(Rails5MigrationStrategy) if defined? ActiveRecord::Migrator - else - ActiveRecord::Migration.send(:include, MigrationStrategy) - ActiveRecord::Migrator.send(:include, MigrationStrategy) if defined? ActiveRecord::Migrator - end + ActiveRecord::Migration.prepend(MigrationStrategy) + ActiveRecord::Migrator.prepend(MigrationStrategy) if defined? ActiveRecord::Migrator end end