Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

deprecated project on rubyforge

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 test
Octocat-spinner-32 .gitignore
Octocat-spinner-32 MIT-LICENSE.txt
Octocat-spinner-32 README
Octocat-spinner-32 Rakefile
README
Deprecated is a module to help you deprecate code BEFORE you remove it. Don't
surprise your users, deprecate them!

Usage is simple:

    class Foo
      include Deprecated

      def moo
        "cow"
      end

      deprecated :moo

      def sheep
        "baaa"
      end

      deprecated :sheep, "Sounds#baa"

      protected

      def bar
        true
      end

      deprecated :bar
    end
    
    Foo.new.moo # warns that the call is deprecated
    
    Deprecated.set_action(:raise)
    Foo.new.moo # raises with the same message

    Deprecated.set_action do |klass, sym, replacement|
      email_boss(
        "Someone tried to use #{klass}##{sym}! " +
        "They should be using #{replacement} instead!"
      )
    end

    Foo.new.sheep # do I really need to explain?

    Foo.new.bar # still protected!

Let's do it live!

    class Bar
      include Deprecated

      # sets it just for this class
      deprecated_set_action do |klass, sym, replacement|
        email_boss(
          "Someone tried to use #{klass}##{sym}! " +
          "They should be using #{replacement} instead!"
        )
      end

      def cow
        "moo"
      end

      deprecate :cow # emails your boss when called!
    end

Please see Deprecated::Module#deprecated, Deprecated.set_action, and
Deprecated::Module#deprecated_set_action for more information.

This library is released under the MIT license:
* http://www.opensource.org/licenses/MIT
Something went wrong with that request. Please try again.