aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/deprecation/method_wrappers.rb
Commit message (Collapse)AuthorAgeFilesLines
* Refactor `ActiveSupport::Deprecation.deprecate_methods` not to expose ↵Ryuta Kamizono2019-04-191-18/+7
| | | | | | | | | | | | | | | | | internal methods In #33325, `deprecate_methods` is replaced from `prepend` to completely emurated `alias_method_chain`, it exposed two internal methods `xxx_with_deprecation` and `xxx_without_deprecation`. After that, #34648 restored the `prepend` implementation, which doesn't expose any internal methods, so we no longer be able to ensure to always expose that internal methods. As I said at https://github.com/rails/rails/pull/33325#issuecomment-409016725, I think that internal methods exposed is not a specification but a limitation when using `alias_method_chain`, there is no longer a reason to follow that limitation.
* Module#{define_method,alias_method,undef_method,remove_method} become public ↵Ryuta Kamizono2018-12-211-4/+4
| | | | | | since Ruby 2.5 https://bugs.ruby-lang.org/issues/14133
* Make `deprecate` work for non-exists methodsyuuji.yaginuma2018-12-071-14/+24
| | | | | | | | Before #33325, `deprecate` works for non-exist methods. This is necessary, for example, if want to deprecate dynamically defined methods like attributes methods. Fixes #34646
* Remove unused requireRyuta Kamizono2018-07-311-1/+0
| | | | | "active_support/core_ext/module/aliasing" is no longer used since #19434.
* A regression in deprecate_methods was introduced in a982a42:Edouard CHIN2018-07-301-14/+17
| | | | | | | | | | | - Refactoring alias_chain to Module#prepend broke the possibility to deprecate class methods since the module generated was prepended to the target's instance. A suggestion to fix this was to use `AS#redefine_method` which would solve the problem but with the cost of redefining directly the method. Decided to go with the same alias_chain implementation as before instead. - Fixes #33253
* Preserve original method visibility when deprecating a methodJordan Brough2017-12-131-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* [ci skip] Fix documentation for deprecation method_wrappersIgnat Zakrevsky2017-11-271-8/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Seems like version with class methods doesn't work. ```ruby require "active_support/deprecation.rb" module Fred extend self def aaa; end def bbb; end def ccc; end def ddd; end def eee; end end ActiveSupport::Deprecation.deprecate_methods(Fred, :aaa, bbb: :zzz, ccc: 'use Bar#ccc instead') Fred.aaa Fred.bbb Fred.ccc ``` # produces nothing vs ```ruby require "active_support/deprecation.rb" class Fred def aaa; end def bbb; end def ccc; end def ddd; end def eee; end end ActiveSupport::Deprecation.deprecate_methods(Fred, :aaa, bbb: :zzz, ccc: 'use Bar#ccc instead') Fred.new.aaa Fred.new.bbb Fred.new.ccc ``` produces ``` DEPRECATION WARNING: aaa is deprecated and will be removed from Rails 5.2 (called from <main> at deprications.rb:15) DEPRECATION WARNING: bbb is deprecated and will be removed from Rails 5.2 (use zzz instead) (called from <main> at deprications.rb:16) DEPRECATION WARNING: ccc is deprecated and will be removed from Rails 5.2 (use Bar#ccc instead) (called from <main> at deprications.rb:17) ```
* [Active Support] require_relative => requireAkira Matsuda2017-10-211-2/+2
| | | | This basically reverts 8da30ad6be34339124ba4cb4e36aea260dda12bc
* [Active Support] `rubocop -a --only Layout/EmptyLineAfterMagicComment`Koichi ITO2017-07-111-0/+1
|
* Use frozen-string-literal in ActiveSupportKir Shatrov2017-07-091-0/+1
|
* [Active Support] require => require_relativeAkira Matsuda2017-07-011-2/+2
|
* Fix the return of `deprecate_methods` in doc [ci skip]kenta-s2017-02-141-1/+1
|
* applies new string literal convention in activesupport/libXavier Noria2016-08-061-2/+2
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Update deprecation_horizon to 5.1 from 5.0 [ci skip]Ryuta Kamizono2016-01-141-3/+3
|
* Fix bug where custom deprecators are not used.Brandon Dunne2015-10-141-12/+36
| | | | | | | | | | | | Add tests for ActiveSupport::Deprecation.deprecate_methods Modify ActiveSupport::Testing::Deprecation to allow a custom deprecator Leverage ActiveSupport::Testing::Deprecation assert_deprecated Update documentation for ActiveSupport::Deprecation.deprecate_methods Use cases: Using the default deprecator => "removed from Rails X.Y" Passing a custom deprecator in the options hash => "removed from MyGem next-release" Deprecating methods directly from custom deprecator => "removed from MyGem next-release"
* Only prepend a single module when defining deprecation wrappers.Charles Oliver Nutter2015-10-131-4/+4
| | | | | I could not find any reason why each method got its own prepended module here, and all tests appear to pass with my change.
* Deprecate alias_method_chain in favour of Module#prependKir Shatrov2015-03-221-3/+5
| | | …as discussed #19413
* Make caller attribute in deprecation methods optionalAlexey Gaziev2012-10-301-1/+1
|
* Change ActiveSupport::Deprecation to class.Piotr Niełacny2012-09-131-38/+33
| | | | | | | | | | | | | | | | | | | | | | | | ActiveSupport::Deprecation is now a class rather than a module. You can get instance of ActiveSupport::Deprecation calling #instance method. ActiveSupport::Deprecation.instance But when you need to get new object od ActiveSupport::Deprecation you need to just call #new. @instance = ActiveSupport::Deprecation.new Since you can create a new object, you can change the version and the name of the library where the deprecator concerned. ActiveSupport::Deprecation.new('2.0', 'MyGem') If you need use another deprecator instance you can select it in the options of deprecate method. deprecate :method, :deprecator => deprecator_instance Documentation has been updated.
* extend ActiveSupport::Deprecation with self, allow other objects to ↵Robert Pankowecki2012-09-131-2/+3
| | | | | | | | | | extend/include it also. test local deprecation deprecator object Test ActiveSupport::Deprecation when included
* add example to AS::Deprecation#deprecate_methods [ci skip]Francesco Rodriguez2012-06-181-0/+20
|
* revises requires of some AS deprecation filesXavier Noria2012-04-051-2/+2
|
* Remove not used require from as to avoid circular requiresCarlos Antonio da Silva2012-04-051-1/+0
|
* Commented metaprogramming turned out to be noisier not clearerJeremy Kemper2010-02-251-9/+9
|
* method_wrappers.rb needs active_support/core_ext/array/extract_optionsXavier Noria2010-01-011-0/+1
|
* Fix deprecating =-methods by using send [#2431 status:resolved]Michael Siebert2009-08-091-9/+9
| | | | Signed-off-by: José Valim <jose.valim@gmail.com>
* Fix dependencies revealed by testing in isolationJeremy Kemper2009-04-221-0/+1
|
* Merge branch 'master' into cherryJeremy Kemper2009-04-201-1/+1
| | | | | | | | | | | Conflicts: activesupport/CHANGELOG activesupport/lib/active_support/core_ext/class/delegating_attributes.rb activesupport/lib/active_support/core_ext/hash/conversions.rb activesupport/lib/active_support/core_ext/module/attribute_accessors.rb activesupport/lib/active_support/core_ext/string/multibyte.rb activesupport/lib/active_support/core_ext/time/calculations.rb activesupport/lib/active_support/deprecation.rb
* Dice up ActiveSupport::DeprecationJeremy Kemper2009-04-171-0/+27