Class: Ansible::Ruby::DslBuilders::JinjaItemNode

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

Instance Method Summary collapse

Constructor Details

#initialize(contexts = 'item') ⇒ JinjaItemNode

Returns a new instance of JinjaItemNode.



6
7
8
# File 'lib/ansible/ruby/dsl_builders/jinja_item_node.rb', line 6

def initialize(contexts = 'item')
  @contexts = [*contexts]
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(id) ⇒ Object

we need to respond to everything, don’t want super rubocop:disable Style/MethodMissing



25
26
27
28
# File 'lib/ansible/ruby/dsl_builders/jinja_item_node.rb', line 25

def method_missing(id, *)
  contexts = @contexts + [id]
  JinjaItemNode.new contexts
end

Instance Method Details

#+(other) ⇒ Object



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

def +(other)
  to_s + other.to_s
end

#to_sObject



14
15
16
17
# File 'lib/ansible/ruby/dsl_builders/jinja_item_node.rb', line 14

def to_s
  flat = @contexts.join '.'
  "{{ #{flat} }}"
end

#to_strObject



19
20
21
# File 'lib/ansible/ruby/dsl_builders/jinja_item_node.rb', line 19

def to_str
  to_s
end