Class: Ansible::Ruby::DslBuilders::Tasks

Inherits:
Base
  • Object
show all
Defined in:
lib/ansible/ruby/dsl_builders/tasks.rb

Direct Known Subclasses

Play

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Base

#jinja, #method_missing

Constructor Details

#initialize(context) ⇒ Tasks

Returns a new instance of Tasks.



12
13
14
15
16
# File 'lib/ansible/ruby/dsl_builders/tasks.rb', line 12

def initialize(context)
  @context = context
  @task_builders = []
  @includes = []
end

Dynamic Method Handling

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

Class Method Details

.context(context) ⇒ Object



30
31
32
# File 'lib/ansible/ruby/dsl_builders/tasks.rb', line 30

def context(context)
  contexts[context]
end

.contextsObject



34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/ansible/ruby/dsl_builders/tasks.rb', line 34

def contexts
  {
    tasks: {
      valid_methods: [:task],
      model: Models::Task
    },
    handlers: {
      valid_methods: [:handler],
      model: Models::Handler
    }
  }
end

Instance Method Details

#_resultObject

allow multiple tasks, etc.



23
24
25
26
27
# File 'lib/ansible/ruby/dsl_builders/tasks.rb', line 23

def _result
  tasks = @task_builders.map(&:_result)
  Models::Tasks.new items: tasks,
                    inclusions: @includes
end

#ansible_include(filename, &block) ⇒ Object



18
19
20
# File 'lib/ansible/ruby/dsl_builders/tasks.rb', line 18

def ansible_include(filename, &block)
  @includes << _ansible_include(filename, &block)
end

#respond_to_missing?(id) ⇒ Boolean

Returns:

  • (Boolean)


48
49
50
# File 'lib/ansible/ruby/dsl_builders/tasks.rb', line 48

def respond_to_missing?(id, *)
  _valid_methods.include? id
end