Class: OpsWorker::Stack

Inherits:
Object
  • Object
show all
Defined in:
lib/ops_worker/stack.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(id, name, region, opsworks_client) ⇒ Stack

Returns a new instance of Stack.



5
6
7
8
9
10
# File 'lib/ops_worker/stack.rb', line 5

def initialize(id, name, region, opsworks_client)
  @id = id
  @name = name
  @region = region
  @opsworks_client = opsworks_client
end

Instance Attribute Details

#idObject (readonly)

Returns the value of attribute id.



3
4
5
# File 'lib/ops_worker/stack.rb', line 3

def id
  @id
end

#nameObject (readonly)

Returns the value of attribute name.



3
4
5
# File 'lib/ops_worker/stack.rb', line 3

def name
  @name
end

#regionObject (readonly)

Returns the value of attribute region.



3
4
5
# File 'lib/ops_worker/stack.rb', line 3

def region
  @region
end

Instance Method Details

#appsObject



12
13
14
15
16
17
18
19
20
21
# File 'lib/ops_worker/stack.rb', line 12

def apps
  if @apps
    return @apps
  end

  apps_result = @opsworks_client.describe_apps(:stack_id => @id)[:apps]
  @apps = apps_result.map do |app_hash|
    App.new(app_hash[:app_id], app_hash[:name], app_hash[:app_source][:revision], self, @opsworks_client)
  end
end

#layersObject



23
24
25
26
27
28
29
30
31
32
# File 'lib/ops_worker/stack.rb', line 23

def layers
  if @layers
    return @layers
  end

  layers_result = @opsworks_client.describe_layers(:stack_id => @id)[:layers]
  @layers = layers_result.map do |layer_hash|
    Layer.new(layer_hash[:layer_id], layer_hash[:name], layer_hash[:type], self, @opsworks_client)
  end
end

#reloadObject



38
39
40
41
# File 'lib/ops_worker/stack.rb', line 38

def reload
  @layers = nil
  @apps = nil
end

#to_sObject



34
35
36
# File 'lib/ops_worker/stack.rb', line 34

def to_s
  "#<OpsWorker::Stack #{@id}, #{@name}, #{@region}>"
end