Skip to content

Commit

Permalink
[Fix #722] Remove alias_method_chain, use Module#prepend instead
Browse files Browse the repository at this point in the history
  • Loading branch information
Dalton committed Feb 24, 2021
1 parent 3ba07cc commit 09ae6ef
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 18 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 2 additions & 18 deletions lib/chewy/railtie.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

Expand Down

0 comments on commit 09ae6ef

Please sign in to comment.