class Configuration

Attributes

factories[R]

Public Class Methods

new() click to toggle source
# File lib/factory_hero/configuration.rb, line 5
def initialize
  @factories = {}
end

Public Instance Methods

clear!() click to toggle source
# File lib/factory_hero/configuration.rb, line 21
def clear!
  factories.clear
end
load_factory(symbol) click to toggle source
# 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) click to toggle source
# File lib/factory_hero/configuration.rb, line 9
def register_factory factory
  raise_if_exists factory.symbol

  factories[factory.symbol] = factory
end

Private Instance Methods

factory_already_defined_exception(symbol) click to toggle source
# File lib/factory_hero/configuration.rb, line 37
def factory_already_defined_exception symbol
  raise FactoryAlreadyDefined.new(symbol), 'There is already a factory defined with this name'
end
raise_if_exists(symbol) click to toggle source
# File lib/factory_hero/configuration.rb, line 27
def raise_if_exists symbol
  return unless factories.has_key? symbol

  factory_already_defined_exception symbol
end
undefined_factory_exception(symbol) click to toggle source
# File lib/factory_hero/configuration.rb, line 33
def undefined_factory_exception symbol
  raise UndefinedFactory.new(symbol), 'No factory definition with this name'
end