class DTK::DSL::Template::V1::Node
Public Class Methods
elements_collection_type()
click to toggle source
For parsing
# File lib/dsl/template/v1/node.rb, line 33 def self.elements_collection_type :hash end
generate_elements(nodes_content, parent)
click to toggle source
For generation
# File lib/dsl/template/v1/node.rb, line 50 def self.generate_elements(nodes_content, parent) nodes_content.inject({}) do |h, (name, node)| node_hash = generate_element?(node, parent) node_hash ? h.merge(name => node_hash) : h end end
parse_elements(input_hash, parent_info)
click to toggle source
# File lib/dsl/template/v1/node.rb, line 37 def self.parse_elements(input_hash, parent_info) input_hash.inject(file_parser_output_hash) do |h, (name, content)| # The term' content || {}' is in case node has no attributes or components h.merge(name => parse_element(content || {}, parent_info, :index => name)) end end
Public Instance Methods
generate!()
click to toggle source
# File lib/dsl/template/v1/node.rb, line 57 def generate! merge(generate_node_hash) end
parse!()
click to toggle source
# File lib/dsl/template/v1/node.rb, line 44 def parse! set? :Attributes, parse_child_elements?(:node_attribute, :Attributes) set? :Components, parse_child_elements?(:component, :Components) end
Private Instance Methods
generate_node_hash()
click to toggle source
# File lib/dsl/template/v1/node.rb, line 63 def generate_node_hash ret = {} set_generation_hash(ret, :Attributes, generate_child_elements(:node_attribute, val(:Attributes))) set_generation_hash(ret, :Components, generate_child_elements(:component, val(:Components))) ret end