To get a chain of alias methods for an object of a certain class, you must call alias_method_chainthe class itself, not its instance. If you want to create a chain of class methods, the same rule applies: you must call alias_method_chainthe classton class, which can be obtained as follows:
klass = class << Client; self; end
In this case, Clientis an instance of the class klass(which has the class Classas its superclass).
:
class Client
def self.mapping
puts 'mapping'
end
def self.mapping_with_safety
puts 'safety'
mapping_without_safety
end
class << self
alias_method_chain :mapping, :safety
end
end
Client.mapping