Module: Canivete::Deprecate

Defined in:
lib/canivete/deprecate.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



3
4
5
# File 'lib/canivete/deprecate.rb', line 3

def self.included(base)
  base.extend Deprecate
end

Instance Method Details

#deprecate(opts = {}) ⇒ Object



20
21
22
# File 'lib/canivete/deprecate.rb', line 20

def deprecate(opts = {})
  @_deprecation_options = opts
end

#method_added(method_name) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/canivete/deprecate.rb', line 7

def method_added(method_name)
  unless @_deprecation_options.nil?
    module_eval <<END
      alias_method :deprecated_#{method_name}, :#{method_name}
      def #{method_name}(*args, &block)
        warn "#{build_message(method_name)}"
        deprecated_#{method_name}(*args, &block)
      end
END
  end
  super
end