Class: IsolatedDatabaseService::ServerList
- Inherits:
-
Object
- Object
- IsolatedDatabaseService::ServerList
- Defined in:
- lib/isolated_database_service.rb
Instance Attribute Summary collapse
-
#next_id ⇒ Object
Returns the value of attribute next_id.
-
#servers ⇒ Object
Returns the value of attribute servers.
Instance Method Summary collapse
- #add_server(server) ⇒ Object
- #clear ⇒ Object
- #count ⇒ Object
- #delete_server(id) ⇒ Object
-
#initialize ⇒ ServerList
constructor
A new instance of ServerList.
Constructor Details
#initialize ⇒ ServerList
Returns a new instance of ServerList.
13 14 15 16 |
# File 'lib/isolated_database_service.rb', line 13 def initialize @next_id = 1 @servers = {} end |
Instance Attribute Details
#next_id ⇒ Object
Returns the value of attribute next_id.
11 12 13 |
# File 'lib/isolated_database_service.rb', line 11 def next_id @next_id end |
#servers ⇒ Object
Returns the value of attribute servers.
11 12 13 |
# File 'lib/isolated_database_service.rb', line 11 def servers @servers end |
Instance Method Details
#add_server(server) ⇒ Object
18 19 20 21 22 23 |
# File 'lib/isolated_database_service.rb', line 18 def add_server(server) id = @next_id @servers[id] = server @next_id += 1 id end |
#clear ⇒ Object
33 34 35 36 |
# File 'lib/isolated_database_service.rb', line 33 def clear @servers = {} @next_id = 1 end |
#count ⇒ Object
29 30 31 |
# File 'lib/isolated_database_service.rb', line 29 def count @servers.length end |
#delete_server(id) ⇒ Object
25 26 27 |
# File 'lib/isolated_database_service.rb', line 25 def delete_server(id) @servers.delete(id) end |