Module: DTK::DSL::Template::V1::ComponentLink::ImplicitLinkName
- Defined in:
- lib/dsl/template/v1/component_link/implicit_link_name.rb
Class Method Summary collapse
- .implicit_link_name(dependent_component_ref) ⇒ Object
-
.parse(dependent_component_ref, opts = {}) ⇒ Object
opts can have keys: :parent :donot_raise_error.
Class Method Details
.implicit_link_name(dependent_component_ref) ⇒ Object
40 41 42 43 |
# File 'lib/dsl/template/v1/component_link/implicit_link_name.rb', line 40 def self.implicit_link_name(dependent_component_ref) # This should not return nil, but allowing it to be more robust parse(dependent_component_ref, donot_raise_error: true) end |
.parse(dependent_component_ref, opts = {}) ⇒ Object
opts can have keys:
:parent
:donot_raise_error
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/dsl/template/v1/component_link/implicit_link_name.rb', line 24 def self.parse(dependent_component_ref, opts = {}) last_component = dependent_component_ref.split('/').last # remove title if it exists title_split = last_component.split('[') case title_split.size when 1 return last_component when 2 return title_split[0] if title_split[1] =~ /\]$/ end unless opts[:donot_raise_error] raise opts[:parent].parsing_error("The term '#{dependent_component_ref}' is an ill-formed component link dependency reference") end nil end |