module DTK::DSL::Template::V1::ComponentLink::ImplicitLinkName

Public Class Methods

parse(dependent_component_ref, opts = {}) click to toggle source

opts can have keys:

:parent
:donot_raise_error
# 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