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.
-
#command ⇒ Object
readonly
Returns the value of attribute command.
-
#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: [], command: nil) ⇒ 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: [], command: nil) ⇒ Service
Returns a new instance of Service.
5 6 7 8 9 10 11 12 |
# File 'lib/rascal/service.rb', line 5 def initialize(name, env_variables: {}, image:, alias_name:, volumes: [], command: nil) @name = name @container = Docker::Container.new(name, image) @alias = alias_name @volumes = volumes @env_variables = env_variables @command = [*command] 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 |
#command ⇒ Object (readonly)
Returns the value of attribute command.
3 4 5 |
# File 'lib/rascal/service.rb', line 3 def command @command 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
27 28 29 |
# File 'lib/rascal/service.rb', line 27 def clean @container.clean end |
#download_missing ⇒ Object
14 15 16 |
# File 'lib/rascal/service.rb', line 14 def download_missing @container.download_missing end |
#start_if_stopped(network: nil) ⇒ Object
18 19 20 21 22 23 24 25 |
# File 'lib/rascal/service.rb', line 18 def start_if_stopped(network: nil) unless @container.running? if (container_id = @container.id) network.disconnect(container_id) end @container.start(network: network, network_alias: @alias, volumes: @volumes, env: @env_variables, command: @command) end end |
#update(**args) ⇒ Object
31 32 33 |
# File 'lib/rascal/service.rb', line 31 def update(**args) @container.update(**args) end |