Class: DTK::DSL::Template::V1::ComponentLink

Inherits:
DTK::DSL::Template::V1 show all
Defined in:
lib/dsl/template/v1/component_link.rb,
lib/dsl/template/v1/component_link/semantic_parse.rb

Defined Under Namespace

Modules: Constant Classes: SemanticParse

Constant Summary

Constants inherited from DTK::DSL::Template::V1

VERSION

Instance Attribute Summary

Attributes included from NestedDSLFile::Mixin

#nested_file_content

Attributes included from Generation::Mixin

#filter, #top

Attributes included from Parsing::Mixin

#file_obj, #parent_key

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from DTK::DSL::Template::V1

#dsl_version, #template_version

Methods inherited from DTK::DSL::Template

#add, create_for_generation, create_for_parsing, #initialize, #merge, #req, #set, #set?, #val

Methods included from Parsing::ClassMixin

#elements_collection_type, #file_parser_output_array, #file_parser_output_hash, #parse_element, #parse_elements

Methods included from Generation::ClassMixin

#generate_elements

Methods included from Generation::Mixin

#generate_yaml_file_path__content_array, #generate_yaml_object, #generate_yaml_object?, #generate_yaml_text, #yaml_object_type

Methods included from Parsing::Mixin

#parse, #parsing_error

Constructor Details

This class inherits a constructor from DTK::DSL::Template

Class Method Details

.elements_collection_typeObject



36
37
38
# File 'lib/dsl/template/v1/component_link.rb', line 36

def self.elements_collection_type
  :hash
end

.generate_elements(component_links_content, parent) ⇒ Object

For generation



52
53
54
55
56
57
58
# File 'lib/dsl/template/v1/component_link.rb', line 52

def self.generate_elements(component_links_content, parent)
  component_links_content.inject({}) do |h, (component_link_name, component_link)| 
    component_link.set(:Name, component_link_name)
    element = generate_element?(component_link, parent)
    element.nil? ? h : h.merge(element)
  end
end

.parse_elements(input_hash, parent_info) ⇒ Object



40
41
42
43
44
# File 'lib/dsl/template/v1/component_link.rb', line 40

def self.parse_elements(input_hash, parent_info)
  input_hash.inject(file_parser_output_hash) do |h, (name, value)|
    h.merge(name => parse_element({ 'value' => value}, parent_info, :index => name))
  end
end

Instance Method Details

#generate!Object



60
61
62
63
64
65
66
# File 'lib/dsl/template/v1/component_link.rb', line 60

def generate!
  value = val(:Value)
  unless value.nil?
    merge(req(:Name) => val(:Value))
    self
  end
end

#generate?Boolean

Returns:

  • (Boolean)


68
69
70
# File 'lib/dsl/template/v1/component_link.rb', line 68

def generate?
  generate! unless skip_for_generation?
end

#parse!Object



46
47
48
49
# File 'lib/dsl/template/v1/component_link.rb', line 46

def parse!
  # using 'input_key_value?' (i.e., with '?') in case null value
  set :Value, input_key_value?(:Value)
end

#parser_output_typeObject

For parsing



32
33
34
# File 'lib/dsl/template/v1/component_link.rb', line 32

def parser_output_type
  :hash
end