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, #vars

Methods inherited from Base

#jinja, #method_missing, #respond_to_missing?

Constructor Details

#initializeBlock

Returns a new instance of Block.



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

def initialize
  super
  @task_builders = []
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



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

def _result
  tasks = @task_builders.map(&:_result)
  args = {
    tasks: tasks
  }.merge @task_args
  block = Models::Block.new args
  block.validate!
  block
end

#task(name, &block) ⇒ Object



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

def task(name, &block)
  task_builder = Task.new name, Models::Task
  task_builder.instance_eval(&block)
  @task_builders << task_builder
  task_builder._register
end