Class: RobotArmy::GateKeeper
Instance Attribute Summary collapse
-
#connection_class ⇒ Object
readonly
Returns the value of attribute connection_class.
Class Method Summary collapse
Instance Method Summary collapse
- #close ⇒ Object
- #connect(host) ⇒ Object
- #connections ⇒ Object
- #establish_connection(host) ⇒ Object
-
#initialize(connection_class = RobotArmy::OfficerConnection) ⇒ GateKeeper
constructor
A new instance of GateKeeper.
Constructor Details
#initialize(connection_class = RobotArmy::OfficerConnection) ⇒ GateKeeper
Returns a new instance of GateKeeper.
4 5 6 |
# File 'lib/robot-army/gate_keeper.rb', line 4 def initialize(connection_class=RobotArmy::OfficerConnection) @connection_class = connection_class end |
Instance Attribute Details
#connection_class ⇒ Object (readonly)
Returns the value of attribute connection_class.
2 3 4 |
# File 'lib/robot-army/gate_keeper.rb', line 2 def connection_class @connection_class end |
Class Method Details
.shared_instance ⇒ Object
25 26 27 |
# File 'lib/robot-army/gate_keeper.rb', line 25 def self.shared_instance @shared_instance ||= new end |
Instance Method Details
#close ⇒ Object
21 22 23 |
# File 'lib/robot-army/gate_keeper.rb', line 21 def close connections.each { |host,c| c.close unless c.closed? } end |
#connect(host) ⇒ Object
8 9 10 |
# File 'lib/robot-army/gate_keeper.rb', line 8 def connect(host) connections[host] ||= establish_connection(host) end |
#connections ⇒ Object
17 18 19 |
# File 'lib/robot-army/gate_keeper.rb', line 17 def connections @connections ||= {} end |
#establish_connection(host) ⇒ Object
12 13 14 15 |
# File 'lib/robot-army/gate_keeper.rb', line 12 def establish_connection(host) connection = connections[host] = connection_class.new(host) connection.open end |