Top Level Namespace

Defined Under Namespace

Modules: Daemoned, MessageQueue, Sweatshop

Instance Method Summary collapse

Instance Method Details

#check_arity!(method, args) ⇒ Object

Raises:

  • (ArgumentError)


7
8
9
10
11
# File 'lib/sweatshop/metaid.rb', line 7

def check_arity!(method, args)
  arity = method.arity
  valid = arity < 0 ? args.size >= arity.abs - 1 : args.size == arity
  raise ArgumentError.new("#{method.name} expects #{arity} arguments") unless valid
end

#meta_def(name, &blk) ⇒ Object



3
4
5
# File 'lib/sweatshop/metaid.rb', line 3

def meta_def(name, &blk)
  meta_eval { define_method name, &blk }
end

#meta_eval(&blk) ⇒ Object



2
# File 'lib/sweatshop/metaid.rb', line 2

def meta_eval(&blk); metaclass.instance_eval(&blk); end

#metaclassObject



1
# File 'lib/sweatshop/metaid.rb', line 1

def metaclass; class << self; self; end; end