Skip to content

shioyama/method_found

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
bin
 
 
lib
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

MethodFound

Gem Version Build Status

Intercept method_missing and do something useful with it.

Installation

Add to your Gemfile:

gem 'method_found', '~> 0.1.6'

And bundle it.

Usage

Include an instance of MethodFound::Builder with a block defining all patterns to match. Identify a pattern with the intercept method, like this:

class Foo
  include MethodFound::Builder.new {
    intercept /\Asay_([a-z]+)\Z/ do |method_name, matches, *arguments, &block|
      "#{matches[1]}!"
    end
  }
end

Now you can say things:

foo = Foo.new
foo.say_hello
#=> "hello!"
foo.say_bye
#=> "bye!"

That's it!

More Information

License

The gem is available as open source under the terms of the MIT License.

About

Intercept method_missing calls and do something useful.

Topics

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published