Module Multimethod
In: lib/multimethod.rb
lib/multimethod/core_extensions.rb
lib/multimethod/method.rb
lib/multimethod/multimethod.rb
lib/multimethod/multimethod_version.rb
lib/multimethod/parameter.rb
lib/multimethod/signature.rb
lib/multimethod/table.rb

Introduction

The Multimethod package implements dispatch of messages to multiple methods based on argument types.

Variadic methods and default values are supported.

Methods can be added and removed at run-time.

Examples

 require 'multimethod'

 class A
   multimethod %q{
   def foo(x) # matches any argument type
      "#{x.inspect}"
   end
   }

   multimethod %q{
   def foo(Fixnum x) # matches any Fixnum
      "Fixnum #{x.inspect}"
   end
   }

   multimethod %q{
   def foo(Numeric x) # matches any Numeric
      "Numeric #{x.inspect}"
   end
   }
 end

 a = A.new
 puts a.foo(:symbol) # ==> ":symbol"
 puts a.foo(45)      # ==> "Fixnum 45"
 puts a.foo(12.34)   # ==> "Numeric 12.34"

Known Issues

This library is not yet thread-safe, due to caching mechanisms used to increase performance. This will be fixed in a future release.

Home page

Credits

Multimethod was developed by:

  • Kurt Stephens — ruby-multimethod(at)umleta.com, sponsored by umleta.com

Contributors

Maybe you?

See Also

Classes and Modules

Module Multimethod::ObjectExtension
Class Multimethod::Method
Class Multimethod::Multimethod
Class Multimethod::Parameter
Class Multimethod::Signature
Class Multimethod::Table

Constants

MultimethodVersion = '0.2.2'   DO NOT EDIT This file is auto-generated by build scripts. See: rake update_version

[Validate]