Class: Rddd::Services::ServiceFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/rddd/services/service_factory.rb

Constant Summary collapse

StrategyNotGiven =
Class.new(RuntimeError)
InvalidService =
Class.new(RuntimeError)

Class Method Summary collapse

Class Method Details

.build(name, attributes) ⇒ Object

Raises:



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/rddd/services/service_factory.rb', line 10

def self.build(name, attributes)
  strategy = Configuration.instance.service_factory_strategy

  raise StrategyNotGiven unless strategy

  begin
    strategy.call(name).new(attributes)
  rescue
    raise Rddd::Services::ServiceFactory::InvalidService
  end
end