Module: Cottus::Forward

Included in:
Client, Connection
Defined in:
lib/cottus/forward.rb

Instance Method Summary collapse

Instance Method Details

#forward(*args) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/cottus/forward.rb', line 5

def forward(*args)
  options = args.pop
  to, through = options.values_at(:to, :through)

  args.each do |verb|
    define_method(verb) do |path, opts={}|
      if to && through
        instance_variable_get(to).send(through, verb, path, opts)
      else
        self.send(to, verb, path, opts)
      end
    end
  end
end