Class: TappingDevice::Trackable::AsyncCollectionProxy

Inherits:
CollectionProxy show all
Defined in:
lib/tapping_device/trackable.rb

Overview

AsyncCollectionProxy delegates chained actions to multiple device “asyncronously” when we use tapping methods like ‘tap_init!` to create sub-devices we need to find a way to pass the chained actions to every sub-device that’s created and this can only happen asyncronously as we won’t know when’ll that happen

Constant Summary

Constants inherited from CollectionProxy

CollectionProxy::CHAINABLE_ACTIONS

Instance Method Summary collapse

Constructor Details

#initialize(devices = []) ⇒ AsyncCollectionProxy

Returns a new instance of AsyncCollectionProxy.



110
111
112
113
# File 'lib/tapping_device/trackable.rb', line 110

def initialize(devices = [])
  super
  @blocks = {}
end

Instance Method Details

#<<(device) ⇒ Object



122
123
124
125
126
127
128
# File 'lib/tapping_device/trackable.rb', line 122

def <<(device)
  @devices << device

  @blocks.each do |method, block|
    device.send(method, &block)
  end
end