New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deprecate alias_method_chain in favour of Module#prepend #19434
Conversation
We are still using it internally right? Lets remove all the calls before deprecating. |
@@ -21,6 +21,8 @@ class Module | |||
# | |||
# so you can safely chain foo, foo?, foo! and/or foo= with the same feature. | |||
def alias_method_chain(target, feature) | |||
ActiveSupport::Deprecation.warn("alias_method_chain is deprecated. Please, use Module#prepend instead.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
alias_method_chain
is usually used to extend an existing method and call the original. This deprecation method leaves the last part implicit. Let's mention you can access the original method using super.
@rafaelfranca done. Now there still 2 places where
|
@kirs in Rage core_ext lets remove the usage of |
@rafaelfranca done! |
Deprecate alias_method_chain in favour of Module#prepend
I don't see how this is a replacement? Prepend operates on the whole module, requires the method that's beind prepended to call super. If we would have gotten the proposed features of before/after/around, that would have been a straight up replacement. This isn't. |
@dhh the method that call |
When we proposed |
Ah, okay, maybe I missed that. I’ll have another look.
|
Right. Let me know if you find a case, so we can remove the deprecation. |
@@ -1,3 +1,7 @@ | |||
* Deprecate `alias_method_chain` in favour of `Module#prepend` introduced in Ruby 2.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@kirs Rails tries to stick to american english, so next time prefer favor over favour etc. 😄
- #alias_method_chain has been deprecated in Rails 5 See: rails/rails#19434
- #alias_method_chain has been deprecated in Rails 5 See: rails/rails#19434
"active_support/core_ext/module/aliasing" is no longer used since #19434.
alias_method_chain was deprecated in Rails 5.0 and removed in 5.1 rails/rails#19434 As the method we're overriding here is a class method rather than an instance method, the suggested fix of using Module#prepend doesn't seem to work so have switched to this simpler - albeit clumsy - fix instead of copying in the original method (in lieu of the renamed method technique we were relying on before) and adding overriding the original class method with `alias_method` instead Inspired by CachedResource's solution: https://github.com/MeisterLabs/cached_resource/blob/4a16812812ec427784d95c803b5d15a3db6d8e42/lib/cached_resource/caching.rb
alias_method_chain was deprecated in Rails 5.0 and removed in 5.1 rails/rails#19434 As the method we're overriding here is a class method rather than an instance method, the suggested fix of using Module#prepend doesn't seem to work so have switched to this simpler - albeit clumsy - fix instead of copying in the original method (in lieu of the renamed method technique we were relying on before) and adding overriding the original class method with `alias_method` instead Inspired by CachedResource's solution: https://github.com/MeisterLabs/cached_resource/blob/4a16812812ec427784d95c803b5d15a3db6d8e42/lib/cached_resource/caching.rb
alias_method_chain was deprecated in Rails 5.0 and removed in 5.1 [1] Class methods are spilt between two modules because of a RSpec mock issue [2]. We're using: - include: to allow the `alert_survey` method to still be mocked in our specs - prepend: to allows us to override a method and call `super` to run the original implementation of the method in Alaveteli core. [1] rails/rails#19434 [2] rspec/rspec-mocks#1213
alias_method_chain was deprecated in Rails 5.0 and removed in 5.1 [1] Class methods are spilt between two modules because of a RSpec mock issue [2]. We're using: - include: to allow the `alert_survey` method to still be mocked in our specs - prepend: to allows us to override a method and call `super` to run the original implementation of the method in Alaveteli core. [1] rails/rails#19434 [2] rspec/rspec-mocks#1213
…as discussed #19413
@rafaelfranca