Module: Forwarder

Defined in:
lib/forwarder.rb,
lib/forwarder/meta.rb,
lib/forwarder/VERSION.rb

Defined Under Namespace

Modules: Meta

Constant Summary

VERSION =
"0.1.1"

Instance Method Summary collapse

Instance Method Details

#forward(message, opts = {}, &blk) ⇒ Object

delegates (forwards) a message to an object (indicated by :to)



8
9
10
11
12
# File 'lib/forwarder.rb', line 8

def forward message, opts={}, &blk
  opts = parse_opts opts, blk
#    p opts: opts
  forward_without_parsing message, opts
end

#forward_all(*messages, &blk) ⇒ Object

Raises:

  • (ArgumentError)


14
15
16
17
18
19
20
21
# File 'lib/forwarder.rb', line 14

def forward_all *messages, &blk
  opts = messages.pop
  raise ArgumentError, "need a Hash as last arg" unless Hash === opts
  opts = parse_opts opts, blk
  messages.each do | msg |
    forward_without_parsing msg, opts
  end
end

#forward_to_self(message, opts = {}) ⇒ Object



23
24
25
# File 'lib/forwarder.rb', line 23

def forward_to_self message, opts={}
  forwarding_with message, opts.merge( to: lambda{ |*args| self } )
end