Class: Boxcutter::LoadBalancer::Backend

Inherits:
Object
  • Object
show all
Defined in:
lib/boxcutter/load_balancer/backend.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api, attrs) ⇒ Backend

Returns a new instance of Backend.



5
6
7
8
# File 'lib/boxcutter/load_balancer/backend.rb', line 5

def initialize(api, attrs)
  @api = api
  @attrs = attrs
end

Instance Attribute Details

#apiObject (readonly)

Returns the value of attribute api.



3
4
5
# File 'lib/boxcutter/load_balancer/backend.rb', line 3

def api
  @api
end

Instance Method Details

#add_machine(machine_id, options = {}) ⇒ Object



30
31
32
# File 'lib/boxcutter/load_balancer/backend.rb', line 30

def add_machine(machine_id, options = {})
  api.create_machine(id, machine_id, options)
end

#idObject



18
19
20
# File 'lib/boxcutter/load_balancer/backend.rb', line 18

def id
  @attrs["id"]
end

#machinesObject



22
23
24
# File 'lib/boxcutter/load_balancer/backend.rb', line 22

def machines
  api.machines(id).map {|attrs| Machine.new(self, api, attrs)}
end

#nameObject



14
15
16
# File 'lib/boxcutter/load_balancer/backend.rb', line 14

def name
  @attrs["backend_name"]
end

#remove_machine(machine_id) ⇒ Object



26
27
28
# File 'lib/boxcutter/load_balancer/backend.rb', line 26

def remove_machine(machine_id)
  api.delete_machine(id, machine_id)
end

#to_sObject



10
11
12
# File 'lib/boxcutter/load_balancer/backend.rb', line 10

def to_s
  "#<Backend id:'#{id}' name:'#{name}'>"
end