Class: Rascal::Service
- Inherits:
-
Object
- Object
- Rascal::Service
- Defined in:
- lib/rascal/service.rb
Instance Attribute Summary collapse
-
#alias ⇒ Object
readonly
Returns the value of attribute alias.
-
#container ⇒ Object
readonly
Returns the value of attribute container.
-
#env_variables ⇒ Object
readonly
Returns the value of attribute env_variables.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
Instance Method Summary collapse
- #clean ⇒ Object
- #download_missing ⇒ Object
-
#initialize(name, env_variables: {}, image:, alias_name:, volumes: []) ⇒ Service
constructor
A new instance of Service.
- #start_if_stopped(network: nil) ⇒ Object
- #update(**args) ⇒ Object
Constructor Details
#initialize(name, env_variables: {}, image:, alias_name:, volumes: []) ⇒ Service
Returns a new instance of Service.
5 6 7 8 9 10 11 |
# File 'lib/rascal/service.rb', line 5 def initialize(name, env_variables: {}, image:, alias_name:, volumes: []) @name = name @container = Docker::Container.new(name, image) @alias = alias_name @volumes = volumes @env_variables = env_variables end |
Instance Attribute Details
#alias ⇒ Object (readonly)
Returns the value of attribute alias.
3 4 5 |
# File 'lib/rascal/service.rb', line 3 def alias @alias end |
#container ⇒ Object (readonly)
Returns the value of attribute container.
3 4 5 |
# File 'lib/rascal/service.rb', line 3 def container @container end |
#env_variables ⇒ Object (readonly)
Returns the value of attribute env_variables.
3 4 5 |
# File 'lib/rascal/service.rb', line 3 def env_variables @env_variables end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
3 4 5 |
# File 'lib/rascal/service.rb', line 3 def name @name end |
Instance Method Details
#clean ⇒ Object
23 24 25 |
# File 'lib/rascal/service.rb', line 23 def clean @container.clean end |
#download_missing ⇒ Object
13 14 15 |
# File 'lib/rascal/service.rb', line 13 def download_missing @container.download_missing end |
#start_if_stopped(network: nil) ⇒ Object
17 18 19 20 21 |
# File 'lib/rascal/service.rb', line 17 def start_if_stopped(network: nil) unless @container.running? @container.start(network: network, network_alias: @alias, volumes: @volumes, env: @env_variables) end end |
#update(**args) ⇒ Object
27 28 29 |
# File 'lib/rascal/service.rb', line 27 def update(**args) @container.update(**args) end |