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.



8
9
10
# File 'lib/ansible/ruby/dsl_builders/jinja_item_node.rb', line 8

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



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

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

Instance Method Details

#+(other) ⇒ Object



12
13
14
# File 'lib/ansible/ruby/dsl_builders/jinja_item_node.rb', line 12

def +(other)
  to_s + other.to_s
end

#flat_contextObject



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

def flat_context
  @contexts.join '.'
end

#to_sObject



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

def to_s
  "{{ #{flat_context} }}"
end

#to_strObject



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

def to_str
  to_s
end