Module: Forwarder
- Defined in:
- lib/forwarder.rb,
lib/forwarder/meta.rb,
lib/forwarder/VERSION.rb
Defined Under Namespace
Modules: Meta
Constant Summary collapse
- VERSION =
"0.1.1"
Instance Method Summary collapse
-
#forward(message, opts = {}, &blk) ⇒ Object
delegates (forwards) a message to an object (indicated by :to).
- #forward_all(*messages, &blk) ⇒ Object
- #forward_to_self(message, opts = {}) ⇒ Object
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 , opts={}, &blk opts = parse_opts opts, blk # p opts: opts forward_without_parsing , opts end |
#forward_all(*messages, &blk) ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/forwarder.rb', line 14 def forward_all *, &blk opts = .pop raise ArgumentError, "need a Hash as last arg" unless Hash === opts opts = parse_opts opts, blk .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 , opts={} forwarding_with , opts.merge( to: lambda{ |*args| self } ) end |