I was trying to understand this call:
deprecate :new_record?, :new?
which uses this deprecate method:
def deprecate(old_method, new_method)
class_eval <<-RUBY, __FILE__, __LINE__ + 1
def #{old_method}(*args, &block)
warn "\#{self.class}##{old_method} is deprecated," +
"use \#{self.class}##{new_method} instead"
send(#{new_method.inspect}, *args, &block)
end
RUBY
end
I don't really understand the metaprogramming that's being used here. But, is this just another way of aliasing the new_record?
method - so in effect, new_record?
is still available but it issues a warning when you use it? Would anyone like to explain how this works?