Method: DataMapper::Hook::ClassMethods#args_for

Defined in:
lib/dm-core/support/hook.rb

#args_for(method) ⇒ Object

— Helpers —



376
377
378
379
380
381
382
383
384
385
386
# File 'lib/dm-core/support/hook.rb', line 376

def args_for(method)
  if method.arity == 0
    "&block"
  elsif method.arity > 0
    "_" << (1 .. method.arity).to_a.join(", _") << ", &block"
  elsif (method.arity + 1) < 0
    "_" << (1 .. (method.arity).abs - 1).to_a.join(", _") << ", *args, &block"
  else
    "*args, &block"
  end
end