Module: Webgen::ContentProcessor::Deprecated

Included in:
Builder, Erb, Erubis, Haml
Defined in:
lib/webgen/deprecated.rb

Instance Method Summary collapse

Instance Method Details

#deprecate(old, new, obj) ⇒ Object



61
62
63
64
65
66
67
68
69
70
71
# File 'lib/webgen/deprecated.rb', line 61

def deprecate(old, new, obj)
  klass = Class.new
  klass.instance_methods.select {|m| m.to_s !~ /^(__|instance_eval|object_id)/}.each {|m| klass.__send__(:undef_method, m)}
  result = klass.new
  result.instance_eval { @old, @new, @obj = old, new, obj }
  def result.method_missing(sym, *args, &block)
    Kernel::warn("Deprecation warning (~ #{caller.first}): The alias '#{@old}' will be removed in one of the next releases - use '#{@new}' instead!")
    @obj.send(sym, *args, &block)
  end
  result
end