Class: Murk::Builder::MurkBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/murk/builder/murk_builder.rb

Instance Method Summary collapse

Constructor Details

#initialize(user) ⇒ MurkBuilder

Returns a new instance of MurkBuilder.



6
7
8
9
10
11
# File 'lib/murk/builder/murk_builder.rb', line 6

def initialize user
  @options_builder = OptionsBuilder.new
  @stack_builders = []
  @current_env = nil
  @user = user
end

Instance Method Details

#buildObject



32
33
34
35
36
37
38
39
40
41
# File 'lib/murk/builder/murk_builder.rb', line 32

def build
  Murk.configure(@options_builder.build)

  stack_collection = Murk::Model::StackCollection.new

  @stack_builders.each do |builder|
    stack_collection.add(builder.build)
  end
  stack_collection
end

#env(name, &block) ⇒ Object



18
19
20
21
22
23
# File 'lib/murk/builder/murk_builder.rb', line 18

def env(name, &block)
  @current_env = name
  instance_eval(&block)
  @current_env = nil
  self
end

#options(&block) ⇒ Object



13
14
15
16
# File 'lib/murk/builder/murk_builder.rb', line 13

def options(&block)
  @options_builder.instance_eval(&block)
  self
end

#stack(name, &block) ⇒ Object



25
26
27
28
29
30
# File 'lib/murk/builder/murk_builder.rb', line 25

def stack(name, &block)
  stack_builder = StackBuilder.new(name, user: @user, env: @current_env)
  stack_builder.instance_eval(&block)
  @stack_builders << stack_builder
  self
end