Class: DockerCompose::Service
- Inherits:
-
Object
- Object
- DockerCompose::Service
- Defined in:
- lib/egg/docker_compose/service.rb
Overview
Wraps the definition of docker-compose services
Instance Attribute Summary collapse
-
#command ⇒ Object
Returns the value of attribute command.
-
#dockerfile ⇒ Object
Returns the value of attribute dockerfile.
-
#environment ⇒ Object
readonly
Returns the value of attribute environment.
-
#image ⇒ Object
Returns the value of attribute image.
-
#links ⇒ Object
readonly
Returns the value of attribute links.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#ports ⇒ Object
Returns the value of attribute ports.
-
#volumes ⇒ Object
Returns the value of attribute volumes.
Instance Method Summary collapse
- #env(variable, value) ⇒ Object
-
#initialize(name) ⇒ Service
constructor
A new instance of Service.
- #link(service) ⇒ Object
- #to_hash ⇒ Object
Constructor Details
#initialize(name) ⇒ Service
Returns a new instance of Service.
13 14 15 16 17 18 |
# File 'lib/egg/docker_compose/service.rb', line 13 def initialize(name) @name = name @links = [] @environment = [] end |
Instance Attribute Details
#command ⇒ Object
Returns the value of attribute command.
7 8 9 |
# File 'lib/egg/docker_compose/service.rb', line 7 def command @command end |
#dockerfile ⇒ Object
Returns the value of attribute dockerfile.
7 8 9 |
# File 'lib/egg/docker_compose/service.rb', line 7 def dockerfile @dockerfile end |
#environment ⇒ Object (readonly)
Returns the value of attribute environment.
6 7 8 |
# File 'lib/egg/docker_compose/service.rb', line 6 def environment @environment end |
#image ⇒ Object
Returns the value of attribute image.
7 8 9 |
# File 'lib/egg/docker_compose/service.rb', line 7 def image @image end |
#links ⇒ Object (readonly)
Returns the value of attribute links.
6 7 8 |
# File 'lib/egg/docker_compose/service.rb', line 6 def links @links end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/egg/docker_compose/service.rb', line 6 def name @name end |
#ports ⇒ Object
Returns the value of attribute ports.
7 8 9 |
# File 'lib/egg/docker_compose/service.rb', line 7 def ports @ports end |
#volumes ⇒ Object
Returns the value of attribute volumes.
7 8 9 |
# File 'lib/egg/docker_compose/service.rb', line 7 def volumes @volumes end |
Instance Method Details
#env(variable, value) ⇒ Object
24 25 26 |
# File 'lib/egg/docker_compose/service.rb', line 24 def env(variable, value) @environment << "#{variable}=#{value}" end |
#link(service) ⇒ Object
20 21 22 |
# File 'lib/egg/docker_compose/service.rb', line 20 def link(service) @links << service.name end |
#to_hash ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/egg/docker_compose/service.rb', line 28 def to_hash output = { "environment" => environment, "links" => links, "volumes" => volumes, "ports" => ports } image ? output["image"] = image : output["build"] = "." output["command"] = command if command output.each_with_object({}) { |(k, v), hash| hash[k] = v if v } end |