Class: HyperMesh::ClassConnectionRegulation

Inherits:
Regulation show all
Defined in:
lib/synchromesh/policy.rb

Instance Attribute Summary

Attributes inherited from Regulation

#klass

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Regulation

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

Constructor Details

This class inherits a constructor from HyperMesh::Regulation

Class Method Details

.allowed_optsObject



195
196
197
# File 'lib/synchromesh/policy.rb', line 195

def self.allowed_opts
  [:auto_connect]
end

.connect(channel, acting_user) ⇒ Object



183
184
185
# File 'lib/synchromesh/policy.rb', line 183

def self.connect(channel, acting_user)
  raise "connection failed" unless regulations[channel].connectable?(acting_user)
end

.connections_for(acting_user, auto_connections_only) ⇒ Object



187
188
189
190
191
192
193
# File 'lib/synchromesh/policy.rb', line 187

def self.connections_for(acting_user, auto_connections_only)
  regulations.collect do |channel, regulation|
    next if auto_connections_only && regulation.auto_connect_disabled?
    next if !regulation.connectable?(acting_user)
    channel
  end.compact
end

Instance Method Details

#connectable?(acting_user) ⇒ Boolean

Returns:

  • (Boolean)


179
180
181
# File 'lib/synchromesh/policy.rb', line 179

def connectable?(acting_user)
  regulate_for(acting_user).all? unless regulations.empty? rescue nil
end