Class: Ansible::Ruby::DslBuilders::Args

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

Constant Summary collapse

KERNEL_METHOD_OVERRIDES =

Each of these are normally Ruby methods but we want to control them

%i[system test warn sleep method].freeze

Instance Method Summary collapse

Methods inherited from Base

#_result, #jinja, #method_missing, #respond_to_missing?

Constructor Details

#initialize(recipient, &block) ⇒ Args

Returns a new instance of Args.



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

def initialize(recipient, &block)
  super()
  @error_handler = block
  @recipient = recipient
end

Dynamic Method Handling

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

Instance Method Details

#_process_method(id, *args) ⇒ Object



18
19
20
21
22
23
24
# File 'lib/ansible/ruby/dsl_builders/args.rb', line 18

def _process_method(id, *args)
  setter = "#{id}=".to_sym
  @error_handler[id] if @error_handler && !@recipient.respond_to?(setter)
  value = args.length == 1 ? args[0] : args
  value = _convert_ast_node value
  @recipient.send(setter, value)
end