Class: HyperMesh::InstanceConnectionRegulation
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
Class Method Details
.allowed_opts ⇒ Object
227
228
229
|
# File 'lib/synchromesh/policy.rb', line 227
def self.allowed_opts
[:auto_connect]
end
|
.connect(instance, acting_user) ⇒ Object
208
209
210
211
212
|
# File 'lib/synchromesh/policy.rb', line 208
def self.connect(instance, acting_user)
unless regulations[instance].connectable_to(acting_user, false).include? instance
raise "connection failed"
end
end
|
.connections_for(acting_user, auto_connections_only) ⇒ Object
214
215
216
217
218
219
220
221
222
223
224
225
|
# File 'lib/synchromesh/policy.rb', line 214
def self.connections_for(acting_user, auto_connections_only)
regulations.collect do |_channel, regulation|
regulation.connectable_to(acting_user, auto_connections_only).collect do |obj|
if auto_connections_only
[obj.class.name, obj.id]
else
InternalPolicy.channel_to_string obj
end
end
end.flatten(1)
end
|
Instance Method Details
#connectable_to(acting_user, auto_connections_only) ⇒ Object
203
204
205
206
|
# File 'lib/synchromesh/policy.rb', line 203
def connectable_to(acting_user, auto_connections_only)
return [] if auto_connections_only && auto_connect_disabled?
regulate_for(acting_user).entries.compact.flatten(1) rescue []
end
|