Module: MethodPattern
- Defined in:
- lib/method_pattern.rb,
lib/method_pattern/version.rb
Defined Under Namespace
Classes: PatternMatchedFunction
Constant Summary collapse
- VERSION =
"0.1.2"
Instance Method Summary collapse
Instance Method Details
#defn(name, &definition) ⇒ Object
4 5 6 7 8 9 10 11 12 13 |
# File 'lib/method_pattern.rb', line 4 def defn name, &definition fn = PatternMatchedFunction.new(name) fn.instance_exec(&definition) define_method name do |*args, &block| instance_exec(*args, &fn.match(args)) rescue => e raise e, e., caller[2..-1] end end |