Module: FakerMaker

Extended by:
Base, Configurable
Defined in:
lib/faker_maker.rb,
lib/faker_maker/base.rb,
lib/faker_maker/naming.rb,
lib/faker_maker/factory.rb,
lib/faker_maker/version.rb,
lib/faker_maker/attribute.rb,
lib/faker_maker/auditable.rb,
lib/faker_maker/naming/json.rb,
lib/faker_maker/configuration.rb,
lib/faker_maker/lifecycle_hooks.rb,
lib/faker_maker/definition_proxy.rb,
lib/faker_maker/naming/json_capitalized.rb

Overview

FakerMaker module for generating Fakes

Defined Under Namespace

Modules: Auditable, Base, Configurable, LifecycleHooks, Naming Classes: Attribute, Configuration, DefinitionProxy, Error, Factory, NoSuchAttributeError, NoSuchAttributeNamingStrategy, NoSuchFactoryError

Constant Summary collapse

VERSION =
'1.3.0'

Class Method Summary collapse

Methods included from Base

factory

Methods included from Configurable

configuration, configuration=, configure

Class Method Details

.[](name) ⇒ Object

Raises:



48
49
50
51
52
53
# File 'lib/faker_maker.rb', line 48

def []( name )
  factory = find_factory(name)
  raise NoSuchFactoryError, "No such factory '#{name}'" unless factory

  factory
end

.build(name) ⇒ Object



44
45
46
# File 'lib/faker_maker.rb', line 44

def build( name )
  find_factory( name ).build
end

.factoriesObject



40
41
42
# File 'lib/faker_maker.rb', line 40

def factories
  @factories ||= {}
end

.find_factory(name) ⇒ Object



55
56
57
# File 'lib/faker_maker.rb', line 55

def find_factory( name )
  factories[name]
end

.register_factory(factory) ⇒ Object



35
36
37
38
# File 'lib/faker_maker.rb', line 35

def register_factory( factory )
  factory.assemble
  factories[factory.name] = factory
end

.shut!(name) ⇒ Object



59
60
61
62
63
64
65
# File 'lib/faker_maker.rb', line 59

def shut!( name )
  factory = find_factory( name )
  return unless factory

  factories[name] = nil
  Object.send( :remove_const, factory.class_name )
end

.shut_all!Object



67
68
69
# File 'lib/faker_maker.rb', line 67

def shut_all!
  factories.each_key { |f| shut!( f ) }
end