Class: HyperMesh::ChannelBroadcastRegulation

Inherits:
Regulation show all
Defined in:
lib/synchromesh/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 HyperMesh::Regulation

Class Method Details

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



234
235
236
# File 'lib/synchromesh/policy.rb', line 234

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

.broadcast(policy) ⇒ Object



238
239
240
241
242
243
244
245
246
# File 'lib/synchromesh/policy.rb', line 238

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



248
249
250
# File 'lib/synchromesh/policy.rb', line 248

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