Module: HyperStore::DispatchReceiver
- Defined in:
- lib/hyper-store/dispatch_receiver.rb
Defined Under Namespace
Classes: InvalidOperationError
Instance Attribute Summary collapse
-
#params ⇒ Object
Returns the value of attribute params.
Instance Method Summary collapse
Instance Attribute Details
#params ⇒ Object
Returns the value of attribute params.
5 6 7 |
# File 'lib/hyper-store/dispatch_receiver.rb', line 5 def params @params end |
Instance Method Details
#receives(*args, &block) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/hyper-store/dispatch_receiver.rb', line 7 def receives(*args, &block) # Format the callback to be Proc or Nil callback = format_callback(args) if args.empty? = 'At least one operation must be passed in to the \'receives\' macro' raise InvalidOperationError, end # Loop through receivers and call callback and block on dispatch args.each do |operation| operation.on_dispatch do |params| @params = params callback.call if callback yield params if block end end end |