Class: Borg::Configuration::Stages::Stage

Inherits:
Object
  • Object
show all
Defined in:
lib/borg/configuration/stages.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name, parent) ⇒ Stage

Returns a new instance of Stage.



28
29
30
31
32
# File 'lib/borg/configuration/stages.rb', line 28

def initialize(name, parent)
  @execution_blocks = []
  @name = name
  @parent = parent
end

Instance Attribute Details

#execution_blocksObject

Returns the value of attribute execution_blocks.



20
21
22
# File 'lib/borg/configuration/stages.rb', line 20

def execution_blocks
  @execution_blocks
end

#parentObject

Returns the value of attribute parent.



21
22
23
# File 'lib/borg/configuration/stages.rb', line 21

def parent
  @parent
end

Instance Method Details

#load_into(config) ⇒ Object



34
35
36
37
38
39
40
41
42
43
44
45
46
# File 'lib/borg/configuration/stages.rb', line 34

def load_into(config)
  if config.respond_to?(:stage)
    # Undefine the stage method now that the app:stage config is created
    config_metaclass = class << config; self; end
    config_metaclass.send(:undef_method, 'stage')

    # Create a capistrano variable for stage
    config.instance_exec(@name, &(lambda { |name| set :stage, name }))
  end

  parent.load_into(config)
  @execution_blocks.each { |blk| config.load(&blk) }
end

#nameObject

TODO: We might want to name this differently



24
25
26
# File 'lib/borg/configuration/stages.rb', line 24

def name
  "#{parent.name}:#{@name}"
end