Class: Compose
- Inherits:
-
Object
- Object
- Compose
- Defined in:
- lib/docker-compose/models/compose.rb
Instance Attribute Summary collapse
-
#containers ⇒ Object
readonly
Returns the value of attribute containers.
Instance Method Summary collapse
-
#add_container(container) ⇒ Object
Add a new container to compose.
-
#delete(labels = []) ⇒ Object
Delete a container.
-
#initialize ⇒ Compose
constructor
A new instance of Compose.
-
#kill(labels = []) ⇒ Object
Kill a container.
-
#link_containers ⇒ Object
Create link relations among containers.
-
#start(labels = []) ⇒ Object
Start a container.
-
#stop(labels = []) ⇒ Object
Stop a container.
Constructor Details
#initialize ⇒ Compose
8 9 10 |
# File 'lib/docker-compose/models/compose.rb', line 8 def initialize @containers = {} end |
Instance Attribute Details
#containers ⇒ Object (readonly)
Returns the value of attribute containers.
6 7 8 |
# File 'lib/docker-compose/models/compose.rb', line 6 def containers @containers end |
Instance Method Details
#add_container(container) ⇒ Object
Add a new container to compose
17 18 19 20 |
# File 'lib/docker-compose/models/compose.rb', line 17 def add_container(container) @containers[container.attributes[:label]] = container true end |
#delete(labels = []) ⇒ Object
Delete a container
This method accepts an array of labels. If labels is informed, only those containers with label present in array will be deleted. Otherwise, all containers are deleted
78 79 80 |
# File 'lib/docker-compose/models/compose.rb', line 78 def delete(labels = []) call_container_method(:delete, labels) end |
#kill(labels = []) ⇒ Object
Kill a container
This method accepts an array of labels. If labels is informed, only those containers with label present in array will be killed. Otherwise, all containers are killed
67 68 69 |
# File 'lib/docker-compose/models/compose.rb', line 67 def kill(labels = []) call_container_method(:kill, labels) end |
#link_containers ⇒ Object
Create link relations among containers
25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/docker-compose/models/compose.rb', line 25 def link_containers @containers.each_value do |container| links = container.attributes[:links] next if links.nil? links.each do |service, label| dependency_container = @containers[service] container.add_dependency(dependency_container) end end end |
#start(labels = []) ⇒ Object
Start a container
This method accepts an array of labels. If labels is informed, only those containers with label present in array will be started. Otherwise, all containers are started
45 46 47 |
# File 'lib/docker-compose/models/compose.rb', line 45 def start(labels = []) call_container_method(:start, labels) end |
#stop(labels = []) ⇒ Object
Stop a container
This method accepts an array of labels. If labels is informed, only those containers with label present in array will be stopped. Otherwise, all containers are stopped
56 57 58 |
# File 'lib/docker-compose/models/compose.rb', line 56 def stop(labels = []) call_container_method(:stop, labels) end |