Class: Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/factory_hero/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



5
6
7
# File 'lib/factory_hero/configuration.rb', line 5

def initialize
  @factories = {}
end

Instance Attribute Details

#factoriesObject (readonly)

Returns the value of attribute factories.



3
4
5
# File 'lib/factory_hero/configuration.rb', line 3

def factories
  @factories
end

Instance Method Details

#clear!Object



21
22
23
# File 'lib/factory_hero/configuration.rb', line 21

def clear!
  factories.clear
end

#load_factory(symbol) ⇒ Object



15
16
17
18
19
# File 'lib/factory_hero/configuration.rb', line 15

def load_factory symbol
  factories.fetch(symbol) do |symbol|
    undefined_factory_exception symbol
  end
end

#register_factory(factory) ⇒ Object



9
10
11
12
13
# File 'lib/factory_hero/configuration.rb', line 9

def register_factory factory
  raise_if_exists factory.symbol

  factories[factory.symbol] = factory
end