Module: FakerMaker::Base

Included in:
FakerMaker
Defined in:
lib/faker_maker/base.rb

Overview

Base module for defining the DSL

Instance Method Summary collapse

Instance Method Details

#factory(name, options = {}, &block) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/faker_maker/base.rb', line 6

def factory(name, options = {}, &block)
  factory = FakerMaker.find_factory(name)
  if factory.nil?
    factory = FakerMaker::Factory.new name, options
    proxy = DefinitionProxy.new factory
    proxy.instance_eval( &block ) if block_given?
    FakerMaker.register_factory factory
  else
    factory
  end
end