Class: Cfhighlander::Factory::ComponentFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/cfhighlander.factory.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(component_sources = [], parent_path = nil) ⇒ ComponentFactory

Returns a new instance of ComponentFactory.



16
17
18
19
# File 'lib/cfhighlander.factory.rb', line 16

def initialize(component_sources = [], parent_path=nil)
  @template_finder = Cfhighlander::Factory::TemplateFinder.new(component_sources, parent_path)
  @component_sources = component_sources
end

Instance Attribute Details

#component_sourcesObject

Returns the value of attribute component_sources.



14
15
16
# File 'lib/cfhighlander.factory.rb', line 14

def component_sources
  @component_sources
end

Instance Method Details

#buildComponentFromLocation(template_meta, component_name) ⇒ Object



36
37
38
39
40
41
42
43
# File 'lib/cfhighlander.factory.rb', line 36

def buildComponentFromLocation(template_meta, component_name)
  component = Model::Component.new(template_meta,
      component_name,
      self)
  component.factory = self
  component.load_config
  return component
end

#loadComponentFromTemplate(template_name, template_version = nil, component_name = nil) ⇒ Cfhighlander::Factory::Component

Find component and given list of sources

Returns:

  • (Cfhighlander::Factory::Component)

Raises:

  • (StandardError)


23
24
25
26
27
28
29
30
31
32
33
# File 'lib/cfhighlander.factory.rb', line 23

def loadComponentFromTemplate(template_name, template_version = nil, component_name = nil)

  template_meta = @template_finder.findTemplate(template_name, template_version)

  raise StandardError, "highlander template #{template_name}@#{template_version} not located" +
      " in sources #{@component_sources}" if template_meta.nil?

  component_name = template_meta.template_name if component_name.nil?
  return buildComponentFromLocation(template_meta, component_name)

end