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,
lib/dsl/template/v1/component_link/implicit_link_name.rb,
lib/dsl/template/v1/component_link/external_service_name.rb

Defined Under Namespace

Modules: Constant, ExternalServiceName, ImplicitLinkName 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, #empty_input_hash, #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!, #generate?, #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

Canonical form is an array



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

def self.elements_collection_type
  :hash
end

.generate_elements(component_links_content, parent) ⇒ Object

For generation



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

def self.generate_elements(component_links_content, parent)
  # Parsing form can be a hash, but canonical form is an array 
  component_links_content.map { |link_name, component_link| generate_canonical_element(link_name, component_link) }
end

.parse_elements(input_hash, parent_info) ⇒ Object



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

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

.parse_transform_to_hash_form(input_links, parent) ⇒ Object



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

def self.parse_transform_to_hash_form(input_links, parent)
  if input_links.kind_of?(::Hash)
    input_links
  elsif input_links.kind_of?(::Array)
    input_links.inject(empty_input_hash) { |h, link| h.merge(ComponentLink.parse_transform_link_to_hash_form(link, parent)) }
  else
    raise parent.parsing_error(:WrongObjectType, input_links, [::Hash, ::Array])
  end
end

Instance Method Details

#parse!Object



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

def parse!
  dependency, external_service_name = parse_value
  set :Value, dependency
  set? :ExternalServiceName, external_service_name
end

#parser_output_typeObject

For parsing



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

def parser_output_type
  :hash
end