Class: Object

Inherits:
BasicObject
Defined in:
lib/cig.rb

Instance Method Summary collapse

Instance Method Details

#cig(*args) ⇒ Object Also known as: _?



2
3
4
5
6
7
8
9
10
11
12
13
14
# File 'lib/cig.rb', line 2

def cig(*args)
  args = args.dup

  if block_given?
    raise ArgumentError, 'Do not pass this method both a block and other arguments.' if args.any?
    return yield self
  end

  obj, meth = args.first.is_a?(Symbol) ? [self, args.shift] : [args.shift, args.shift]

  send_meth = obj == self ? :send : :public_send
  obj.send send_meth, meth, self, *args
end