Class: VCFB::Resolver

Inherits:
Object
  • Object
show all
Defined in:
lib/vcfb/resolver.rb

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(namespace, form_element = nil) ⇒ Resolver

Returns a new instance of Resolver.



3
4
5
6
# File 'lib/vcfb/resolver.rb', line 3

def initialize(namespace, form_element = nil)
  @namespace = namespace.to_s.underscore
  @form_element = form_element.to_s.underscore unless form_element.nil?
end

Class Method Details

.call(namespace, form_element = nil) ⇒ Object



16
17
18
# File 'lib/vcfb/resolver.rb', line 16

def self.call(namespace, form_element = nil)
  new(namespace, form_element).call
end

Instance Method Details

#callObject



8
9
10
11
12
13
14
# File 'lib/vcfb/resolver.rb', line 8

def call
  component_name = "#{[@namespace, @form_element].compact.join("/")}/component"
  component = component_name.camelize.safe_constantize
  raise Errors::ComponentMissing, "unable to locate component #{component_name}" unless component

  component
end