Class: Kuby::Docker::LayerStack
- Inherits:
-
Object
- Object
- Kuby::Docker::LayerStack
- Includes:
- Enumerable
- Defined in:
- lib/kuby/docker/layer_stack.rb
Instance Attribute Summary collapse
-
#layers ⇒ Object
readonly
Returns the value of attribute layers.
-
#stack ⇒ Object
readonly
Returns the value of attribute stack.
Instance Method Summary collapse
- #delete(name) ⇒ Object
- #each ⇒ Object
-
#initialize ⇒ LayerStack
constructor
A new instance of LayerStack.
- #insert(name, layer, options = {}) ⇒ Object
- #use(name, layer) ⇒ Object
Constructor Details
#initialize ⇒ LayerStack
Returns a new instance of LayerStack.
8 9 10 11 |
# File 'lib/kuby/docker/layer_stack.rb', line 8 def initialize @stack = [] @layers = {} end |
Instance Attribute Details
#layers ⇒ Object (readonly)
Returns the value of attribute layers.
6 7 8 |
# File 'lib/kuby/docker/layer_stack.rb', line 6 def layers @layers end |
#stack ⇒ Object (readonly)
Returns the value of attribute stack.
6 7 8 |
# File 'lib/kuby/docker/layer_stack.rb', line 6 def stack @stack end |
Instance Method Details
#delete(name) ⇒ Object
36 37 38 39 |
# File 'lib/kuby/docker/layer_stack.rb', line 36 def delete(name) stack.delete(name) layers.delete(name) end |
#each ⇒ Object
13 14 15 16 |
# File 'lib/kuby/docker/layer_stack.rb', line 13 def each return to_enum(__method__) unless block_given? @stack.each { |name| yield layers[name] } end |
#insert(name, layer, options = {}) ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/kuby/docker/layer_stack.rb', line 23 def insert(name, layer, = {}) existing_name = [:before] || [:after] idx = stack.index(existing_name) unless idx raise ArgumentError, "Could not find existing layer '#{existing_name}'" end idx += 1 if [:after] stack.insert(idx, name) layers[name] = layer end |
#use(name, layer) ⇒ Object
18 19 20 21 |
# File 'lib/kuby/docker/layer_stack.rb', line 18 def use(name, layer) stack << name layers[name] = layer end |