Class: Ansible::Ruby::DslBuilders::Task

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

Instance Attribute Summary

Attributes inherited from Base

#result

Instance Method Summary collapse

Methods inherited from Base

#method_missing

Constructor Details

#initialize(name) ⇒ Task

Returns a new instance of Task.



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

def initialize(name)
  super()
  @module = nil
  @temp_counter = 0
  @name = name
  @task_args = {}
end

Dynamic Method Handling

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

Instance Method Details

#ansible_when(clause) ⇒ Object



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

def ansible_when(clause)
  @task_args[:when] = clause
end

#async(value) ⇒ Object



54
55
56
# File 'lib/ansible/ruby/dsl_builders/task.rb', line 54

def async(value)
  @task_args[:async] = value
end

#become(*args) ⇒ Object



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

def become(*args)
  value = implicit_bool args
  @task_args[:become] = value
end

#become_user(value) ⇒ Object



34
35
36
# File 'lib/ansible/ruby/dsl_builders/task.rb', line 34

def become_user(value)
  @task_args[:become_user] = value
end

#changed_when(clause) ⇒ Object



38
39
40
# File 'lib/ansible/ruby/dsl_builders/task.rb', line 38

def changed_when(clause)
  @task_args[:changed_when] = clause
end

#evaluateObject



18
19
20
21
22
23
24
25
26
27
# File 'lib/ansible/ruby/dsl_builders/task.rb', line 18

def evaluate(*)
  super
  args = {
    module: @module,
    name: @name
  }.merge @task_args
  task = Models::Task.new args
  task.validate!
  task
end

#failed_when(clause) ⇒ Object



42
43
44
# File 'lib/ansible/ruby/dsl_builders/task.rb', line 42

def failed_when(clause)
  @task_args[:failed_when] = clause
end

#ignore_errors(*args) ⇒ Object



66
67
68
69
# File 'lib/ansible/ruby/dsl_builders/task.rb', line 66

def ignore_errors(*args)
  value = implicit_bool args
  @task_args[:ignore_errors] = value
end

#notify(value) ⇒ Object



62
63
64
# File 'lib/ansible/ruby/dsl_builders/task.rb', line 62

def notify(value)
  @task_args[:notify] = value
end

#poll(value) ⇒ Object



58
59
60
# File 'lib/ansible/ruby/dsl_builders/task.rb', line 58

def poll(value)
  @task_args[:poll] = value
end

#respond_to_missing?Boolean

Returns:

  • (Boolean)


71
72
73
# File 'lib/ansible/ruby/dsl_builders/task.rb', line 71

def respond_to_missing?(*)
  !@module || super
end

#with_dict(clause) ⇒ Object



50
51
52
# File 'lib/ansible/ruby/dsl_builders/task.rb', line 50

def with_dict(clause)
  @task_args[:with_dict] = clause
end