Class: EcsDeployCli::DSL::Service

Inherits:
Object
  • Object
show all
Includes:
AutoOptions
Defined in:
lib/ecs_deploy_cli/dsl/service.rb

Defined Under Namespace

Classes: LoadBalancer

Instance Method Summary collapse

Methods included from AutoOptions

#_options, #method_missing

Constructor Details

#initialize(name, config) ⇒ Service

Returns a new instance of Service.



8
9
10
11
# File 'lib/ecs_deploy_cli/dsl/service.rb', line 8

def initialize(name, config)
  _options[:service] = name
  @config = config
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class EcsDeployCli::DSL::AutoOptions

Instance Method Details

#as_definition(task) ⇒ Object



30
31
32
33
34
35
36
37
# File 'lib/ecs_deploy_cli/dsl/service.rb', line 30

def as_definition(task)
  {
    cluster: @config[:cluster],
    service: _options[:service],
    task_definition: task,
    load_balancers: @load_balancers&.map(&:as_definition) || []
  }
end

#load_balancer(name, &block) ⇒ Object



21
22
23
24
25
26
27
28
# File 'lib/ecs_deploy_cli/dsl/service.rb', line 21

def load_balancer(name, &block)
  @load_balancers ||= []

  load_balancer = LoadBalancer.new(name, @config)
  load_balancer.instance_exec(&block)

  @load_balancers << load_balancer
end

#optionsObject



17
18
19
# File 'lib/ecs_deploy_cli/dsl/service.rb', line 17

def options
  _options
end

#task(name) ⇒ Object



13
14
15
# File 'lib/ecs_deploy_cli/dsl/service.rb', line 13

def task(name)
  _options[:task] = name
end