Class: Hyperloop::InstanceConnectionRegulation

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

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 Hyperloop::Regulation

Class Method Details

.allowed_optsObject


314
315
316
# File 'lib/hyper-operation/transport/policy.rb', line 314

def self.allowed_opts
  [:auto_connect]
end

.connect(instance, acting_user) ⇒ Object


295
296
297
298
299
# File 'lib/hyper-operation/transport/policy.rb', line 295

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


301
302
303
304
305
306
307
308
309
310
311
312
# File 'lib/hyper-operation/transport/policy.rb', line 301

def self.connections_for(acting_user, auto_connections_only)
  regulations.collect do |_channel, regulation|
    # the following was bizarelly passing true for auto_connections_only????
    regulation.connectable_to(acting_user, auto_connections_only).collect do |obj|
      if false && auto_connections_only # false added to try to get channel instances to connect???
        [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


290
291
292
293
# File 'lib/hyper-operation/transport/policy.rb', line 290

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