Class: Kontena::Stacks::StackDataSet

Inherits:
Object
  • Object
show all
Defined in:
lib/kontena/stacks/stack_data_set.rb

Instance Method Summary collapse

Constructor Details

#initialize(data) ⇒ StackDataSet

Returns a new instance of StackDataSet.

Parameters:

  • data (Hash)


7
8
9
# File 'lib/kontena/stacks/stack_data_set.rb', line 7

def initialize(data)
  @data = data
end

Instance Method Details

#delete(name) ⇒ StackData, NilClass

Parameters:

Returns:



39
40
41
42
# File 'lib/kontena/stacks/stack_data_set.rb', line 39

def delete(name)
  data = @data.delete(name)
  StackData.new(data[:stack_data], data[:loader]) if data
end

#remove_dependenciesArray<StackData>

Returns:



45
46
47
48
49
# File 'lib/kontena/stacks/stack_data_set.rb', line 45

def remove_dependencies
  stacks.map do |stack|
    delete(stack.name) unless stack.root?
  end.compact
end

#sizeInteger

Returns:

  • (Integer)


33
34
35
# File 'lib/kontena/stacks/stack_data_set.rb', line 33

def size
  @data.size
end

#stack(name) ⇒ StackData, NilClass Also known as: []

Parameters:

Returns:



13
14
15
16
# File 'lib/kontena/stacks/stack_data_set.rb', line 13

def stack(name)
  data = @data[name]
  StackData.new(data[:stack_data], data[:loader]) if data
end

#stack_namesArray<String>

Returns:



28
29
30
# File 'lib/kontena/stacks/stack_data_set.rb', line 28

def stack_names
  @data.keys
end

#stacksArray<StackData>

Returns:



21
22
23
24
25
# File 'lib/kontena/stacks/stack_data_set.rb', line 21

def stacks
  stack_names.map do |name|
    stack(name)
  end.compact
end