Class: Ansible::Ruby::DslBuilders::Block

Inherits:
Unit
  • Object
show all
Defined in:
lib/ansible/ruby/dsl_builders/block.rb

Instance Method Summary collapse

Methods inherited from Unit

#ansible_when, #become, #become_user, #ignore_errors

Methods inherited from Base

#jinja, #method_missing, #respond_to_missing?

Constructor Details

#initializeBlock

Returns a new instance of Block.



8
9
10
11
12
# File 'lib/ansible/ruby/dsl_builders/block.rb', line 8

def initialize
  super
  @tasks = []
  @temp_counter = 0
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Ansible::Ruby::DslBuilders::Base

Instance Method Details

#_resultObject

allow for other attributes besides the module in any order



22
23
24
25
26
27
28
29
# File 'lib/ansible/ruby/dsl_builders/block.rb', line 22

def _result
  args = {
    tasks: @tasks
  }.merge @task_args
  block = Models::Block.new args
  block.validate!
  block
end

#task(name, &block) ⇒ Object



14
15
16
17
18
19
# File 'lib/ansible/ruby/dsl_builders/block.rb', line 14

def task(name, &block)
  @temp_counter += 1
  task_builder = Task.new name, Models::Task, @temp_counter
  task_builder.instance_eval(&block)
  @tasks << task_builder._result
end