Module: FactoryHero

Defined in:
lib/factory_hero.rb,
lib/factory_hero/version.rb

Constant Summary collapse

VERSION =
"1.0.0"

Class Method Summary collapse

Class Method Details

.build(klass_or_symbol, attrs = {}) ⇒ Object



21
22
23
24
25
26
# File 'lib/factory_hero.rb', line 21

def self.build klass_or_symbol, attrs = {}
  symbol = klass_or_symbol.symbolize
  factory = configuration.load_factory symbol

  factory.build attrs
end

.clear!Object



28
29
30
# File 'lib/factory_hero.rb', line 28

def self.clear!
  configuration.clear!
end

.configurationObject



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

def self.configuration
  @@configuration ||= Configuration.new
end

.define_factory(klass_or_symbol, options = {}, &block) ⇒ Object



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

def self.define_factory klass_or_symbol, options = {}, &block
  symbol = klass_or_symbol.symbolize

  configuration.register_factory Factory.new symbol, options, &block
end