meta_missing

require "meta_missing"

class AnimalFarm
  prepend MetaMissing

  handle_methods_like(/pony/) do |regexp, name, *args, &block|
    [self, regexp, name, args, block_given?, block, block[]]
  end

  handle_methods_like(/kitties/) do
    ["Meow meow meow", block_given?]
  end
end

And then try the following:

> AnimalFarm.new.mecha_pony(1, 2, 3) { 4 }
> AnimalFarm.new.kitties

#=> [#<AnimalFarm:0x007fbfc08c5bb8>, #<MatchData "pony">, :mecha_pony, [1, 2, 3], true, #<Proc:0x007fbfc08c5b40@(pry)>, 4]
#=> ["Meow meow meow", false]

Contrast this with:

> AnimalFarm.new.pigs

#=> NoMethodError: undefined method `pigs' for #<Foo:0x007fd74fccab90>

Contributing to meta_missing

Copyright © 2014 Evan Senter. See LICENSE.txt for further details.