3 # Create a private alias for the instance method named +method_name+
4 # of class +klass+. The string representation of +id+ will be part
5 # of the alias to ease debugging. This method makes sure that the
6 # alias doesn't redefine an existing method.
8 # Returns the name of the new alias.
10 # In the simplest case, the alias will be
11 # <tt>"#{method_name}_without_#{id}"</tt>.
12 def self.create_alias(klass, method_name, id)
13 basename = "#{method_name}_without_#{id}"
18 break unless klass.method_defined?(new_name)
20 new_name = "#{basename}_#{i}"
23 klass.send(:alias_method, new_name, method_name)
24 klass.send(:private, new_name)