Class: Orchestra::DSL::Steps::Context

Inherits:
BasicObject
Defined in:
lib/orchestra/dsl/steps.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(builder) ⇒ Context

Returns a new instance of Context.



32
33
34
# File 'lib/orchestra/dsl/steps.rb', line 32

def initialize builder
  @builder = builder
end

Class Method Details

.evaluate(builder, &block) ⇒ Object



27
28
29
30
# File 'lib/orchestra/dsl/steps.rb', line 27

def self.evaluate builder, &block
  context = new builder
  context.instance_eval &block
end

Instance Method Details

#depends_on(*dependencies) ⇒ Object



36
37
38
39
40
41
42
43
# File 'lib/orchestra/dsl/steps.rb', line 36

def depends_on *dependencies
  defaults, dependencies = Util.extract_hash dependencies
  @builder.dependencies.concat dependencies
  defaults.each do |key, default|
    @builder.dependencies << key
    @builder.defaults[key] = Util.to_lazy_thunk default
  end
end

#execute(&block) ⇒ Object



59
60
61
# File 'lib/orchestra/dsl/steps.rb', line 59

def execute &block
  @builder.execute_block = block
end

#iterates_over(dependency) ⇒ Object



63
64
65
66
# File 'lib/orchestra/dsl/steps.rb', line 63

def iterates_over dependency
  @builder.dependencies << dependency
  @builder.collection = dependency
end

#modifies(provision, args = {}) ⇒ Object



45
46
47
48
49
50
51
52
53
# File 'lib/orchestra/dsl/steps.rb', line 45

def modifies provision, args = {}
  collection, _ = Util.extract_key_args args, :collection => false
  if collection
    iterates_over provision
  else
    depends_on provision
  end
  provides provision
end

#provides(*provisions) ⇒ Object



55
56
57
# File 'lib/orchestra/dsl/steps.rb', line 55

def provides *provisions
  @builder.provisions.concat provisions
end