我想重构这段代码:
class Logger
class << self
def info title, msg
puts hash_for(title, msg, :info ).to_json
end
def unknown title, msg
puts hash_for(title, msg, :unknown).to_json
end
变成这样的东西:
def print title, msg, level
puts hash_for(title, msg, level).to_json
end
alias :info, :print
alias :unknown, :print
但我需要注入这个论点,alias
而且alias_method
似乎并不支持。
红宝石 2.3