Module: Fauna::Deprecate

Included in:
Query
Defined in:
lib/fauna/deprecate.rb

Instance Method Summary collapse

Instance Method Details

#deprecate(name, replacement) ⇒ Object

Deprecates a method

class AClass

extend Fauna::Deprecate

def method
end

deprecate :method, :new_method

def new_method
end

end

name

The method name to be deprecated

replacement

The new method that should be used instead



20
21
22
23
24
25
26
27
# File 'lib/fauna/deprecate.rb', line 20

def deprecate(name, replacement)
  old_name = "deprecated_#{name}"
  alias_method old_name, name
  define_method name do |*args, &block|
    warn "Method #{name} called from #{Gem.location_of_caller.join(':')} is deprecated. Use #{replacement} instead"
    self.__send__ old_name, *args, &block
  end
end