diff options
author | Jordan Brough <git.j@brgh.net> | 2017-12-13 12:46:42 -0700 |
---|---|---|
committer | Jordan Brough <git.j@brgh.net> | 2017-12-13 13:18:03 -0700 |
commit | 9adaf605b4fb0075855c062c30fa4fdd96927b93 (patch) | |
tree | 96f653e61080472c624911c0e04575e8a52be69a /activerecord/test | |
parent | bf4ee05a1b948b76ad76a450a41376804dde57ba (diff) | |
download | rails-9adaf605b4fb0075855c062c30fa4fdd96927b93.tar.gz rails-9adaf605b4fb0075855c062c30fa4fdd96927b93.tar.bz2 rails-9adaf605b4fb0075855c062c30fa4fdd96927b93.zip |
Preserve original method visibility when deprecating a method
This commit fixes `deprecate` so that it preserves method visibility (like it
did previously when it was utilizing `alias_method_chain`).
When Module#prepend replaced alias_method_chain in a982a42 it caused deprecated
methods to always become public.
`alias_method_chain` had this bit of code:
https://github.com/rails/rails/blob/v5.0.6/activesupport/lib/active_support/core_ext/module/aliasing.rb#L40-L47
which preserved method visibility.
Without this fix, a workaround would be:
```ruby
class C8
private
def new_method
end
def old_method
end
deprecate :old_method, :new_method
# workaround:
instance_method(:old_method).owner.send(:private, :old_method)
end
```
Because the visibility needs to be fixed on the Module prepended by
MethodWrapper.
Diffstat (limited to 'activerecord/test')
0 files changed, 0 insertions, 0 deletions