class MultiDispatch::MultiMethod

Public Class Methods

new(obj, unbnd_mthd) click to toggle source
# File lib/multi_dispatch/multi_method.rb, line 8
def initialize(obj, unbnd_mthd)
  @obj, @unbound_method = obj, unbnd_mthd
end

Public Instance Methods

call(*args) click to toggle source
# File lib/multi_dispatch/multi_method.rb, line 12
def call(*args)
  if args.size != arity
    raise ArgumentError,
      "wrong number of arguments(#{args.size} for #{arity})"
  end
  @obj.instance_exec(*args, &@unbound_method.body)
end
receiver() click to toggle source
# File lib/multi_dispatch/multi_method.rb, line 24
def receiver 
  @obj 
end
to_proc() click to toggle source
# File lib/multi_dispatch/multi_method.rb, line 28
def to_proc
  Proc.new { |*args| call(*args) }     
end
unbind() click to toggle source
# File lib/multi_dispatch/multi_method.rb, line 20
def unbind
  @unbound_method
end