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, ChaosConflictingAttributeError, Configuration, DefinitionProxy, Error, Factory, NoSuchAttributeError, NoSuchAttributeNamingStrategy, NoSuchFactoryError

Constant Summary collapse

VERSION =
'2.0.0'

Class Method Summary collapse

Methods included from Base

factory

Methods included from Configurable

configuration, configuration=, configure

Class Method Details

.[](name) ⇒ Object

Raises:



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

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

  factory
end

.build(name) ⇒ Object



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

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

.factoriesObject



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

def factories
  @factories ||= {}
end

.find_factory(name) ⇒ Object



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

def find_factory( name )
  factories[name]
end

.register_factory(factory) ⇒ Object



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

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

.shut!(name) ⇒ Object



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

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

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

.shut_all!Object



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

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