Allow ActiveSupport::Deprecation features to be used by rails applications and library authors #6348

Merged
merged 2 commits into from Sep 13, 2012

Conversation

Projects
None yet
7 participants
@LTe
Contributor

LTe commented May 16, 2012

Updated version of #2310

@rafaelfranca

This comment has been minimized.

Show comment
Hide comment
@jeremy

This comment has been minimized.

Show comment
Hide comment
@jeremy

jeremy May 16, 2012

Member
  1. If we're exposing this for reuse, we need docs! How should a library author use this?
  2. Feels like libraries using separate deprecators should be working with instances of a class rather than extending with a module that injects a bunch of behavior, including its internal state. Could make ActiveSupport::Deprecation a class (without breaking API) and delegate the existing toplevel methods to a singleton ActiveSupport::Deprecation.instance
  3. The #deprecator instance method may be unnecessary. Looks like the only reason we need it is so the deprecated method wrapper can refer to it. It'd be cleaner to pass a deprecator instance and reference it directly from the method wrapper (using define_method instead of class_eval)
Member

jeremy commented May 16, 2012

  1. If we're exposing this for reuse, we need docs! How should a library author use this?
  2. Feels like libraries using separate deprecators should be working with instances of a class rather than extending with a module that injects a bunch of behavior, including its internal state. Could make ActiveSupport::Deprecation a class (without breaking API) and delegate the existing toplevel methods to a singleton ActiveSupport::Deprecation.instance
  3. The #deprecator instance method may be unnecessary. Looks like the only reason we need it is so the deprecated method wrapper can refer to it. It'd be cleaner to pass a deprecator instance and reference it directly from the method wrapper (using define_method instead of class_eval)
@LTe

This comment has been minimized.

Show comment
Hide comment
@LTe

LTe May 18, 2012

Contributor

@jeremy done :)

Contributor

LTe commented May 18, 2012

@jeremy done :)

@jeremy

View changes

activesupport/lib/active_support/deprecation/behaviors.rb
- # Default warning behaviors per Rails.env.
- DEFAULT_BEHAVIORS = {

This comment has been minimized.

@jeremy

jeremy May 18, 2012

Member

Should probably leave these as a constant since it acts as public API now. People add behaviors to this hash directly.

@jeremy

jeremy May 18, 2012

Member

Should probably leave these as a constant since it acts as public API now. People add behaviors to this hash directly.

@jeremy

This comment has been minimized.

Show comment
Hide comment
@jeremy

jeremy May 18, 2012

Member

@LTe Very nice! Looking good.

Member

jeremy commented May 18, 2012

@LTe Very nice! Looking good.

@carlosantoniodasilva

View changes

activesupport/lib/active_support/deprecation/proxy_wrappers.rb
+ # Example
+ # OLD_CONST = ActiveSupport::Deprecation::DeprecatedConstantProxy.new('OLD_CONST', 'NEW_CONST')
+ # Example with custom deprecator
+ # OLD_CONST = ActiveSupport::Deprecation::DeprecatedConstantProxy.new('OLD_CONST', 'NEW_CONST'. deprecator_instance)

This comment has been minimized.

@carlosantoniodasilva

carlosantoniodasilva May 19, 2012

Member

Typo: . instead of , after NEW_CONST.

@carlosantoniodasilva

carlosantoniodasilva May 19, 2012

Member

Typo: . instead of , after NEW_CONST.

@carlosantoniodasilva

View changes

activesupport/lib/active_support/deprecation/reporting.rb
+ # ActiveSupport::Deprecation.deprecated_method_warning(:method_name)
+ # # => "method_name is deprecated and will be removed from Rails #{deprecation_horizon}"
+ # ActiveSupport::Deprecation.deprecated_method_warning(:method_name, :another_method)
+ # # => "method_name is deprecated and will be removed from Rails #{deprecation_horizon} (use another_method instead)"

This comment has been minimized.

@carlosantoniodasilva

View changes

activesupport/test/deprecation_test.rb
+ end
+ end
+
+

This comment has been minimized.

@carlosantoniodasilva

carlosantoniodasilva May 19, 2012

Member

Two lines ✂️

@carlosantoniodasilva

carlosantoniodasilva May 19, 2012

Member

Two lines ✂️

@carlosantoniodasilva

View changes

activesupport/lib/active_support/core_ext/module/deprecation.rb
+ # It will execute
+ # CustomClass::Deprecator.instance.deprecated_method_warning(:foo, "this is very old method").tap |message|
+ # CustomClass::Deprecator.instance.warn(message, backtrace)
+ # end

This comment has been minimized.

@carlosantoniodasilva

carlosantoniodasilva May 19, 2012

Member

The docs are pretty good, but there's no mention of instance in CustomClass::Deprecator, this may confuse people. Perhaps you can just use new instead of instance, or add the method or singleton there to show how it'd look like?

@carlosantoniodasilva

carlosantoniodasilva May 19, 2012

Member

The docs are pretty good, but there's no mention of instance in CustomClass::Deprecator, this may confuse people. Perhaps you can just use new instead of instance, or add the method or singleton there to show how it'd look like?

This comment has been minimized.

@jeremy

jeremy May 23, 2012

Member

Agree -- no need to introduce a singleton for the custom case

@jeremy

jeremy May 23, 2012

Member

Agree -- no need to introduce a singleton for the custom case

@LTe

This comment has been minimized.

Show comment
Hide comment
@LTe

LTe May 19, 2012

Contributor

@carlosantoniodasilva @jeremy thanks for feedback!

Contributor

LTe commented May 19, 2012

@carlosantoniodasilva @jeremy thanks for feedback!

@paneq

This comment has been minimized.

Show comment
Hide comment
@paneq

paneq May 20, 2012

Contributor

What do you think about it:

module ActiveSupport
  class Deprecation
    def initialize(horizon = '3.2', gem_name = 'rails')
      self.deprecation_horizon = horizon
      self.gem_name = gem_name
    end
  end
end

For custom gems authors should create new instances of ActiveSupport::Deprecation to generate proper warning messages. If they use ActiveSupport::Deprecation.instance the message is going to say that something will be removed from rails which is in many cases not what the authors of gems would like to announce to the users.

These:

deprecator = ActiveSupport::Deprecation.new
deprecator.deprecation_horizon = "2.0.0"
ActiveSupport::Deprecation.new.tap{|d| d.deprecation_horizon = "2.0.0" }

seem to be unnecessary verbose to me.

ActiveSupport::Deprecation.new("2.0.0", "formtastic")

looks much better imho.

Contributor

paneq commented May 20, 2012

What do you think about it:

module ActiveSupport
  class Deprecation
    def initialize(horizon = '3.2', gem_name = 'rails')
      self.deprecation_horizon = horizon
      self.gem_name = gem_name
    end
  end
end

For custom gems authors should create new instances of ActiveSupport::Deprecation to generate proper warning messages. If they use ActiveSupport::Deprecation.instance the message is going to say that something will be removed from rails which is in many cases not what the authors of gems would like to announce to the users.

These:

deprecator = ActiveSupport::Deprecation.new
deprecator.deprecation_horizon = "2.0.0"
ActiveSupport::Deprecation.new.tap{|d| d.deprecation_horizon = "2.0.0" }

seem to be unnecessary verbose to me.

ActiveSupport::Deprecation.new("2.0.0", "formtastic")

looks much better imho.

@paneq

This comment has been minimized.

Show comment
Hide comment
@paneq

paneq May 20, 2012

Contributor

Science Fiction:

module ActiveSupport
  class Deprecation
    def initialize(horizon = default_horizon, gem_name = 'rails')
      self.deprecation_horizon = horizon
      self.gem_name = gem_name
    end

    def default_horizon
      "#{ActiveSupport::VERSION::MAJOR}.#{ActiveSupport::VERSION::MINOR + 1}"
    end
  end
end

because sometimes it should be major + 1. Or maybe it should be always major +1 and never minor + 1 ?

Contributor

paneq commented May 20, 2012

Science Fiction:

module ActiveSupport
  class Deprecation
    def initialize(horizon = default_horizon, gem_name = 'rails')
      self.deprecation_horizon = horizon
      self.gem_name = gem_name
    end

    def default_horizon
      "#{ActiveSupport::VERSION::MAJOR}.#{ActiveSupport::VERSION::MINOR + 1}"
    end
  end
end

because sometimes it should be major + 1. Or maybe it should be always major +1 and never minor + 1 ?

@LTe

This comment has been minimized.

Show comment
Hide comment
@LTe

LTe May 21, 2012

Contributor

Now you can create instance of deprecator and create new object via new.
I like @paneq approach -- now this is simple to reuse.

About science fiction I think better solution is pass directly version to initialize method.

Contributor

LTe commented May 21, 2012

Now you can create instance of deprecator and create new object via new.
I like @paneq approach -- now this is simple to reuse.

About science fiction I think better solution is pass directly version to initialize method.

@paneq

This comment has been minimized.

Show comment
Hide comment
@paneq

paneq May 21, 2012

Contributor

"About science fiction I think better solution is pass directly version to initialize method." - probably. Except for the fact that the core team needs to change this one line every time there is new rails version. I wanted to spare them this trouble in this science fiction solution :)

Contributor

paneq commented May 21, 2012

"About science fiction I think better solution is pass directly version to initialize method." - probably. Except for the fact that the core team needs to change this one line every time there is new rails version. I wanted to spare them this trouble in this science fiction solution :)

@LTe

This comment has been minimized.

Show comment
Hide comment
@LTe

LTe May 21, 2012

Contributor

According to http://semver.org/ this always should be major +1

Contributor

LTe commented May 21, 2012

According to http://semver.org/ this always should be major +1

@LTe

This comment has been minimized.

Show comment
Hide comment
@LTe

LTe May 23, 2012

Contributor

@jeremy what do you think? We can merge current implementation?

Contributor

LTe commented May 23, 2012

@jeremy what do you think? We can merge current implementation?

@jeremy

View changes

activesupport/lib/active_support/deprecation/behaviors.rb
# [+log+] Log all deprecation warnings to +Rails.logger+.
- # [+notify+] Use <tt>ActiveSupport::Notifications</tt> to notify +deprecation.rails+.
+ # [+notify] Use +ActiveSupport::Notifications+ to notify +deprecation.rails+.

This comment has been minimized.

@jeremy

jeremy May 23, 2012

Member

[+notify+] formatting changed?

@jeremy

jeremy May 23, 2012

Member

[+notify+] formatting changed?

@jeremy

View changes

activesupport/lib/active_support/deprecation/method_wrappers.rb
+ # Declare that a method has been deprecated.
+ def deprecate_methods(target_module, *method_names)
+ options = method_names.extract_options!
+ deprecator = options.delete(:deprecator) || ActiveSupport::Deprecation

This comment has been minimized.

@jeremy

jeremy May 23, 2012

Member

ActiveSupport::Deprecation.instance here rather than rely on the instance delegator

@jeremy

jeremy May 23, 2012

Member

ActiveSupport::Deprecation.instance here rather than rely on the instance delegator

@jeremy

View changes

activesupport/lib/active_support/deprecation/proxy_wrappers.rb
+ #
+ # Default deprecator is ActiveSupport::Deprecation
+ class DeprecatedObjectProxy < DeprecationProxy
+ def initialize(object, message, deprecator = ActiveSupport::Deprecation)

This comment has been minimized.

@jeremy

jeremy May 23, 2012

Member

.instance here too

@jeremy

jeremy May 23, 2012

Member

.instance here too

@LTe

This comment has been minimized.

Show comment
Hide comment
@LTe

LTe May 23, 2012

Contributor

@jeremy updated and rebased

Contributor

LTe commented May 23, 2012

@jeremy updated and rebased

@jeremy

View changes

activesupport/lib/active_support/deprecation/behaviors.rb
+ # Default warning behaviors per Rails.env.
+ DEFAULT_BEHAVIORS = {
+ :stderr => Proc.new { |message, callstack|
+ $stderr.puts(message)

This comment has been minimized.

@jeremy

jeremy May 23, 2012

Member

Extra indentation here

@jeremy

jeremy May 23, 2012

Member

Extra indentation here

@@ -5,6 +5,36 @@ class Module
# deprecate :foo
# deprecate :bar => 'message'
# deprecate :foo, :bar, :baz => 'warning!', :qux => 'gone!'
+ #
+ # You can use custom deprecator instance

This comment has been minimized.

@jeremy

jeremy May 23, 2012

Member

You can use a custom deprecator object that responds to +warn+ and +deprecated_method_warning+. This is useful when you use +ActiveSupport::Deprecation+ in your own libraries and want to customize deprecation behavior.

@jeremy

jeremy May 23, 2012

Member

You can use a custom deprecator object that responds to +warn+ and +deprecated_method_warning+. This is useful when you use +ActiveSupport::Deprecation+ in your own libraries and want to customize deprecation behavior.

@jeremy

View changes

activesupport/lib/active_support/core_ext/module/deprecation.rb
+ # Example
+ # class CustomClass
+ # class Deprecator
+ # def deprecated_method_warning(method_name, message)

This comment has been minimized.

@jeremy

jeremy May 23, 2012

Member
class MyLib::Deprecator
  def warn(message, backtrace)
    Kernel.warn message
  end

  def deprecated_method_warning(method_name, message)
    "#{method_name} is deprecated and will be removed from MyLibrary | #{message}"
  end
end
@jeremy

jeremy May 23, 2012

Member
class MyLib::Deprecator
  def warn(message, backtrace)
    Kernel.warn message
  end

  def deprecated_method_warning(method_name, message)
    "#{method_name} is deprecated and will be removed from MyLibrary | #{message}"
  end
end

This comment has been minimized.

@jeremy

jeremy May 23, 2012

Member
module MyLib
  mattr_accessor :deprecator
  self.deprecator = Deprecator.new
end
@jeremy

jeremy May 23, 2012

Member
module MyLib
  mattr_accessor :deprecator
  self.deprecator = Deprecator.new
end
@jeremy

View changes

activesupport/lib/active_support/core_ext/module/deprecation.rb
+ # def deprecated_method_warning(method_name, message)
+ # "#{method_name} is deprecated and will be removed from MyLibrary | #{message}"
+ # end
+ #

This comment has been minimized.

@jeremy

jeremy May 23, 2012

Member
class MyLib::Bar
  deprecate :foo => "this is very old method", :deprecator => MyLib.deprecator
end
@jeremy

jeremy May 23, 2012

Member
class MyLib::Bar
  deprecate :foo => "this is very old method", :deprecator => MyLib.deprecator
end
@jeremy

View changes

activesupport/lib/active_support/core_ext/module/deprecation.rb
+ # end
+ # end
+ # end
+ #

This comment has been minimized.

@jeremy

jeremy May 23, 2012

Member

It will build a deprecation warning message by calling MyLib.deprecator.deprecated_method_warning(:foo, "this is a very old method") then invoke the deprecator warning with the message and the caller's backtrace: MyLib.deprecator.warn(warning_message, caller)

@jeremy

jeremy May 23, 2012

Member

It will build a deprecation warning message by calling MyLib.deprecator.deprecated_method_warning(:foo, "this is a very old method") then invoke the deprecator warning with the message and the caller's backtrace: MyLib.deprecator.warn(warning_message, caller)

@jeremy

View changes

activesupport/lib/active_support/core_ext/module/deprecation.rb
- # Declare that a method has been deprecated.
+ # You can use a custom deprecator object that responds to +warn+ and +deprecated_method_warning+.
+ # This is useful when you use +ActiveSupport::Deprecation+ in your own libraries and want to customize
+ # deprecation behavior.

This comment has been minimized.

@jeremy

jeremy May 23, 2012

Member

Can leave these out, they're better demonstrated below

@jeremy

jeremy May 23, 2012

Member

Can leave these out, they're better demonstrated below

@jeremy

View changes

activesupport/lib/active_support/core_ext/module/deprecation.rb
+ # You can use a custom deprecator object that responds to +warn+ and +deprecated_method_warning+.
+ # This is useful when you use +ActiveSupport::Deprecation+ in your own libraries and want to customize
+ # deprecation behavior.
+ #
# deprecate :foo

This comment has been minimized.

@jeremy

jeremy May 23, 2012

Member

Custom deprecators must respond to two methods:

@jeremy

jeremy May 23, 2012

Member

Custom deprecators must respond to two methods:

@jeremy

View changes

activesupport/lib/active_support/core_ext/module/deprecation.rb
+ # You can use a custom deprecator object that responds to +warn+ and +deprecated_method_warning+.
+ # This is useful when you use +ActiveSupport::Deprecation+ in your own libraries and want to customize
+ # deprecation behavior.
+ #
# deprecate :foo
# deprecate :bar => 'message'

This comment has been minimized.

@jeremy

jeremy May 23, 2012

Member

[deprecated_method_warning(method_name, message)] will be called with the deprecated method name and the message it was declared with. Return a warning message.

@jeremy

jeremy May 23, 2012

Member

[deprecated_method_warning(method_name, message)] will be called with the deprecated method name and the message it was declared with. Return a warning message.

@jeremy

View changes

activesupport/lib/active_support/core_ext/module/deprecation.rb
+ # You can use a custom deprecator object that responds to +warn+ and +deprecated_method_warning+.
+ # This is useful when you use +ActiveSupport::Deprecation+ in your own libraries and want to customize
+ # deprecation behavior.
+ #
# deprecate :foo
# deprecate :bar => 'message'
# deprecate :foo, :bar, :baz => 'warning!', :qux => 'gone!'

This comment has been minimized.

@jeremy

jeremy May 23, 2012

Member

[warn(message, backtrace)] will be called with the message from your deprecated_method_warning method and the caller's backtrace. Implement whatever warning behavior you like here.

@jeremy

jeremy May 23, 2012

Member

[warn(message, backtrace)] will be called with the message from your deprecated_method_warning method and the caller's backtrace. Implement whatever warning behavior you like here.

@jeremy

This comment has been minimized.

Show comment
Hide comment
@jeremy

jeremy May 23, 2012

Member

@LTe some comments on the documentation :)

It covers how to give a custom deprecator object, but doesn't show how you can use ActiveSupport::Deprecation.new(version, libname) yourself.

When I read through the duck type for a deprecator, having to implement two methods seems wrong, too. We call deprecator.deprecated_method_warning then pass its return value to #warn -- we could just call one method and let the deprecator handle that internally.

Member

jeremy commented May 23, 2012

@LTe some comments on the documentation :)

It covers how to give a custom deprecator object, but doesn't show how you can use ActiveSupport::Deprecation.new(version, libname) yourself.

When I read through the duck type for a deprecator, having to implement two methods seems wrong, too. We call deprecator.deprecated_method_warning then pass its return value to #warn -- we could just call one method and let the deprecator handle that internally.

@paneq

This comment has been minimized.

Show comment
Hide comment
@paneq

paneq May 23, 2012

Contributor

@jeremy - I think that's because #warn has the logic for outputing to logger, stderr, output or whatever is configured in current development environment and #deprecated_method_warning is just responsible for generting the warning. One might want to generate different warnings for his own gem but keep the logic coherent with Rails as to where they are displayed. What do you think ?

Contributor

paneq commented May 23, 2012

@jeremy - I think that's because #warn has the logic for outputing to logger, stderr, output or whatever is configured in current development environment and #deprecated_method_warning is just responsible for generting the warning. One might want to generate different warnings for his own gem but keep the logic coherent with Rails as to where they are displayed. What do you think ?

@jeremy

This comment has been minimized.

Show comment
Hide comment
@jeremy

jeremy May 23, 2012

Member

@paneq definitely -- and a higher-level method like deprecation_warning(deprecated_method_name, message, caller_backtrace) could wrap that up. Then custom classes can implement that one method whereas subclasses of ActiveSupport::Deprecation can override just deprecated_method_warning if they like.

Member

jeremy commented May 23, 2012

@paneq definitely -- and a higher-level method like deprecation_warning(deprecated_method_name, message, caller_backtrace) could wrap that up. Then custom classes can implement that one method whereas subclasses of ActiveSupport::Deprecation can override just deprecated_method_warning if they like.

@LTe

This comment has been minimized.

Show comment
Hide comment
@LTe

LTe Jun 7, 2012

Contributor

Updated

Contributor

LTe commented Jun 7, 2012

Updated

@LTe

This comment has been minimized.

Show comment
Hide comment
@LTe

LTe Jun 29, 2012

Contributor

@jeremy what do you think about merge?

Contributor

LTe commented Jun 29, 2012

@jeremy what do you think about merge?

@steveklabnik

This comment has been minimized.

Show comment
Hide comment
@steveklabnik

steveklabnik Jul 1, 2012

Member

@LTe it needs rebased at least, it can't be merged cleanly anymore.

Member

steveklabnik commented Jul 1, 2012

@LTe it needs rebased at least, it can't be merged cleanly anymore.

@LTe

This comment has been minimized.

Show comment
Hide comment
@LTe

LTe Jul 2, 2012

Contributor

@steveklabnik rebased ;-)

Contributor

LTe commented Jul 2, 2012

@steveklabnik rebased ;-)

@steveklabnik

This comment has been minimized.

Show comment
Hide comment
@steveklabnik

steveklabnik Jul 2, 2012

Member

Thanks. Let's see what @jeremy says.

Member

steveklabnik commented Jul 2, 2012

Thanks. Let's see what @jeremy says.

@paneq

This comment has been minimized.

Show comment
Hide comment
@paneq

paneq Jul 9, 2012

Contributor

What do you think @jeremy ?

Contributor

paneq commented Jul 9, 2012

What do you think @jeremy ?

@jeremy

This comment has been minimized.

Show comment
Hide comment
@jeremy

jeremy Sep 11, 2012

Member

👍

Member

jeremy commented Sep 11, 2012

👍

+ # Kernel.warn message
+ # end
+ #
+ # end

This comment has been minimized.

@carlosantoniodasilva

carlosantoniodasilva Sep 11, 2012

Member

Please remove whitespaces between the method and class declaration, there's no need for them ✂️

@carlosantoniodasilva

carlosantoniodasilva Sep 11, 2012

Member

Please remove whitespaces between the method and class declaration, there's no need for them ✂️

@carlosantoniodasilva

View changes

activesupport/test/deprecation_test.rb
+ end
+ end
+
+ unless defined?(::MiniTest)

This comment has been minimized.

@carlosantoniodasilva

carlosantoniodasilva Sep 11, 2012

Member

I think this will be always defined, why do you need to test using `Test::Unit::Error in this particular case?

@carlosantoniodasilva

carlosantoniodasilva Sep 11, 2012

Member

I think this will be always defined, why do you need to test using `Test::Unit::Error in this particular case?

This comment has been minimized.

@steveklabnik

steveklabnik Sep 11, 2012

Member

This will be, except on some distros like Fedora which (imho) give you a broken Ruby.

Especially on master, where we only support 1.9, this should basically always be true.

@steveklabnik

steveklabnik Sep 11, 2012

Member

This will be, except on some distros like Fedora which (imho) give you a broken Ruby.

Especially on master, where we only support 1.9, this should basically always be true.

@carlosantoniodasilva

This comment has been minimized.

Show comment
Hide comment
@carlosantoniodasilva

carlosantoniodasilva Sep 11, 2012

Member

@LTe hey, could you please add a changelog entry for this, and check the minor comments I made, so that we can get this in master? Thanks!

@LTe hey, could you please add a changelog entry for this, and check the minor comments I made, so that we can get this in master? Thanks!

@LTe

This comment has been minimized.

Show comment
Hide comment
@LTe

LTe Sep 12, 2012

Contributor

@carlosantoniodasilva updated, rebased.

Contributor

LTe commented Sep 12, 2012

@carlosantoniodasilva updated, rebased.

@carlosantoniodasilva

This comment has been minimized.

Show comment
Hide comment
@carlosantoniodasilva

carlosantoniodasilva Sep 12, 2012

Member

@LTe, great thanks. I'll have to ask you one more thing though, to review your commit message and improve the changelog a bit with an example of how to use this new feature. This will help others to understand the reasoning and how to use the feature at the same time when reading the commits or the changelog.

Here's an explanation about how to go with the commit message, and here's another about changelogs.

I'll merge it afterwards. Thanks!

@LTe, great thanks. I'll have to ask you one more thing though, to review your commit message and improve the changelog a bit with an example of how to use this new feature. This will help others to understand the reasoning and how to use the feature at the same time when reading the commits or the changelog.

Here's an explanation about how to go with the commit message, and here's another about changelogs.

I'll merge it afterwards. Thanks!

paneq and others added some commits Jul 25, 2011

extend ActiveSupport::Deprecation with self, allow other objects to e…
…xtend/include it also.

test local deprecation

deprecator object

Test ActiveSupport::Deprecation when included
Change ActiveSupport::Deprecation to class.
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.
@LTe

This comment has been minimized.

Show comment
Hide comment
@LTe

LTe Sep 13, 2012

Contributor
Contributor

LTe commented Sep 13, 2012

@carlosantoniodasilva

This comment has been minimized.

Show comment
Hide comment
@carlosantoniodasilva

carlosantoniodasilva Sep 13, 2012

Member

@LTe great, thank you!

@LTe great, thank you!

carlosantoniodasilva added a commit that referenced this pull request Sep 13, 2012

Merge pull request #6348 from LTe/no_global_depreactations
Allow ActiveSupport::Deprecation features to be used by rails applications and library authors

@carlosantoniodasilva carlosantoniodasilva merged commit 01ef633 into rails:master Sep 13, 2012

@splattael

This comment has been minimized.

Show comment
Hide comment
@splattael

splattael Sep 13, 2012

Contributor

The definition of self.deprecator should go before this deprecate call.

The definition of self.deprecator should go before this deprecate call.

This comment has been minimized.

Show comment
Hide comment
Member

rafaelfranca replied Sep 13, 2012

Fixed @ 8692db5

This comment has been minimized.

Show comment
Hide comment
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment