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.



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

def initialize(context)
  @context = context
  @tasks = []
  @includes = []
  @temp_counter = 0
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



28
29
30
# File 'lib/ansible/ruby/dsl_builders/tasks.rb', line 28

def context(context)
  contexts[context]
end

.contextsObject



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

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.



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

def _result
  Models::Tasks.new items: @tasks,
                    inclusions: @includes
end

#ansible_include(filename, &block) ⇒ Object



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

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

#respond_to_missing?(id) ⇒ Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/ansible/ruby/dsl_builders/tasks.rb', line 46

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