Class: FactoryGirl::DisallowsDuplicatesRegistry

Inherits:
Object
  • Object
show all
Defined in:
lib/factory_girl/disallows_duplicates_registry.rb

Instance Method Summary collapse

Constructor Details

#initialize(component) ⇒ DisallowsDuplicatesRegistry

Returns a new instance of DisallowsDuplicatesRegistry.



3
4
5
# File 'lib/factory_girl/disallows_duplicates_registry.rb', line 3

def initialize(component)
  @component = component
end

Instance Method Details

#register(name, item) ⇒ Object



9
10
11
12
13
14
15
# File 'lib/factory_girl/disallows_duplicates_registry.rb', line 9

def register(name, item)
  if registered?(name)
    raise DuplicateDefinitionError, "#{@component.name} already registered: #{name}"
  else
    @component.register(name, item)
  end
end