Skip to content
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

[ci skip] Fix documentation for deprecation method_wrappers #31243

Merged
merged 1 commit into from
Nov 27, 2017
Merged

[ci skip] Fix documentation for deprecation method_wrappers #31243

merged 1 commit into from
Nov 27, 2017

Conversation

ignat-z
Copy link
Contributor

@ignat-z ignat-z commented Nov 27, 2017

Seems like version with class methods doesn't work (and seems like it's correct, because of module prepending and define_method creates instance methods).

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

-> nothing

vs

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

->

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)

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)
```
@rafaelfranca rafaelfranca merged commit c22ec97 into rails:master Nov 27, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants