Class: Hyperloop::ChannelBroadcastRegulation

Inherits:
Regulation
  • Object
show all
Defined in:
lib/hyper-operation/transport/policy.rb

Instance Attribute Summary

Attributes inherited from Regulation

#klass

Class Method Summary collapse

Methods inherited from Regulation

allowed_opts, #auto_connect_disabled?, #initialize, #opts, #regulate_for, regulations, #regulations, wrap_policy

Constructor Details

This class inherits a constructor from Hyperloop::Regulation

Class Method Details

.add_regulation(channel, opts = {}, &regulation) ⇒ Object



321
322
323
# File 'lib/hyper-operation/transport/policy.rb', line 321

def add_regulation(channel, opts={}, &regulation)
  regulations_to_channels[regulation] << super
end

.broadcast(policy) ⇒ Object



325
326
327
328
329
330
331
332
333
# File 'lib/hyper-operation/transport/policy.rb', line 325

def broadcast(policy)
  regulations_to_channels.each do |regulation, channels|
    wrapped_policy = wrap_policy(policy, regulation)
    channels.each do |channel|
      regulation.call wrapped_policy
      policy.send_unassigned_sets_to channel.klass
    end
  end
end

.regulations_to_channelsObject



335
336
337
# File 'lib/hyper-operation/transport/policy.rb', line 335

def regulations_to_channels
  @regulations_to_channels ||= Hash.new { |hash, key| hash[key] = [] }
end