幽灵方法:动态生成方法

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

class Lawyer
  def method_missing(method, *args)
    puts "You called: #{method} (#{args.join(', ')})"
    puts "You also passed it a block" if block_given?
  end
end

nick = Lawyer.new
nick.talk_simple('a', 'b') do
  # a block
end