class Noaidi::Module

Public Class Methods

new() click to toggle source
# File lib/noaidi/module.rb, line 7
def initialize
  @funs = {}
end

Public Instance Methods

fun(name, args=[], &block) click to toggle source
# File lib/noaidi/module.rb, line 11
def fun(name, args=[], &block)
  raise NoBlockGiven unless block_given?
  name = name.to_sym
  f = Fun.new(self, name, args, block)
  @funs[name] ||= []
  @funs[name] << f
  f
end
inspect_funs() click to toggle source
# File lib/noaidi/module.rb, line 20
def inspect_funs
  @funs.inspect
end
method_missing(name, *args) click to toggle source
# File lib/noaidi/module.rb, line 24
def method_missing(name, *args)
  find_best_method(name, args).call(*args)
end

Private Instance Methods

find_best_method(name, args) click to toggle source
# File lib/noaidi/module.rb, line 29
def find_best_method(name, args)
  @funs[name].detect { |f| f.matches?(args) }
end