- Notifications
You must be signed in to change notification settings - Fork22.1k
Deprecate alias_method_chain in favour of Module#prepend#19434
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
rafaelfranca commentedMar 20, 2015
We are still using it internally right? Lets remove all the calls before deprecating. |
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.
kirs commentedMar 22, 2015
@rafaelfranca done. Now there still 2 places where
|
rafaelfranca commentedMar 22, 2015
@kirs in Rage core_ext lets remove the usage of |
kirs commentedMar 22, 2015
@rafaelfranca done! |
Deprecate alias_method_chain in favour of Module#prepend
dhh commentedMar 24, 2015
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. |
rafaelfranca commentedMar 24, 2015
@dhh the method that call |
rafaelfranca commentedMar 24, 2015
When we proposed |
dhh commentedMar 24, 2015
Ah, okay, maybe I missed that. I’ll have another look.
|
rafaelfranca commentedMar 24, 2015
Right. Let me know if you find a case, so we can remove the deprecation. |
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 5See:rails/rails#19434
- #alias_method_chain has been deprecated in Rails 5See: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.1rails/rails#19434As the method we're overriding here is a class method rather than aninstance method, the suggested fix of using Module#prepend doesn't seemto work so have switched to this simpler - albeit clumsy - fix insteadof copying in the original method (in lieu of the renamed methodtechnique we were relying on before) and adding overriding the originalclass method with `alias_method` insteadInspired 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.1rails/rails#19434As the method we're overriding here is a class method rather than aninstance method, the suggested fix of using Module#prepend doesn't seemto work so have switched to this simpler - albeit clumsy - fix insteadof copying in the original method (in lieu of the renamed methodtechnique we were relying on before) and adding overriding the originalclass method with `alias_method` insteadInspired 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 mockissue [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 mockissue [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