Class: ActionFactory::FactoryFinder

Inherits:
Object
  • Object
show all
Defined in:
lib/action_factory/factory_finder.rb

Constant Summary collapse

FactoryNotFound =
Class.new(StandardError)

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(name) ⇒ FactoryFinder

Returns a new instance of FactoryFinder.



15
16
17
# File 'lib/action_factory/factory_finder.rb', line 15

def initialize(name)
  @name = name
end

Class Method Details

.factory_class_for(name) ⇒ Object



10
11
12
# File 'lib/action_factory/factory_finder.rb', line 10

def factory_class_for(name)
  new(name).factory_class
end

Instance Method Details

#factory_classObject



19
20
21
22
23
24
# File 'lib/action_factory/factory_finder.rb', line 19

def factory_class
  factory_class_name = Registry.factory_class_name_for(@name)
  factory_class_name.constantize
rescue NameError
  raise FactoryNotFound, "Factory with class name #{factory_class_name.inspect} not found"
end