Class: Hyperloop::ClassConnectionRegulation
Instance Attribute Summary
Attributes inherited from Regulation
#klass
Class Method Summary
collapse
Instance Method Summary
collapse
Methods inherited from Regulation
#auto_connect_disabled?, #initialize, #opts, #regulate_for, #regulations, regulations, wrap_policy
Class Method Details
.add_regulation(klass, opts = {}, ®ulation) ⇒ Object
203
204
205
206
207
|
# File 'lib/hyper-operation/transport/policy.rb', line 203
def self.add_regulation(klass, opts={}, ®ulation)
actual_klass = klass.is_a?(Class) ? klass : klass.constantize rescue nil
actual_klass.dispatch_to(actual_klass) if actual_klass.respond_to? :dispatch_to rescue nil
super
end
|
.allowed_opts ⇒ Object
225
226
227
|
# File 'lib/hyper-operation/transport/policy.rb', line 225
def self.allowed_opts
[:auto_connect]
end
|
.connect(channel, acting_user) ⇒ Object
213
214
215
|
# File 'lib/hyper-operation/transport/policy.rb', line 213
def self.connect(channel, acting_user)
raise "connection failed" unless regulations[channel].connectable?(acting_user)
end
|
.connections_for(acting_user, auto_connections_only) ⇒ Object
217
218
219
220
221
222
223
|
# File 'lib/hyper-operation/transport/policy.rb', line 217
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
209
210
211
|
# File 'lib/hyper-operation/transport/policy.rb', line 209
def connectable?(acting_user)
regulate_for(acting_user).all? unless regulations.empty? rescue nil
end
|