Sha256: 146a8c079b07f2596cd26d96265d23dea76c7504bc4ead01dea78597f7ecec99

Contents?: true

Size: 988 Bytes

Versions: 4

Compression:

Stored size: 988 Bytes

Contents

require 'active_support'
require 'active_support/core_ext/string'
require 'active_support/core_ext/hash'
require 'active_support/core_ext/object/json'
require 'faker_maker/version'
require 'faker_maker/base'
require 'faker_maker/factory'
require 'faker_maker/definition_proxy'
require 'faker_maker/attribute'

# FakerMaker module for generating Fakes
module FakerMaker
  extend FakerMaker::Base

  class Error < StandardError; end
  class NoSuchFactoryError < StandardError; end
  class NoSuchAttributeError < StandardError; end
  # Your code goes here...

  module_function

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

  def factories
    @factories ||= {}
  end

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

  def []( name )
    find_factory name
  end
  
  def find_factory( name )
    raise NoSuchFactoryError, "No such factory '#{name}'" if factories[name].nil?
    
    factories[name]
  end
end

FM = FakerMaker

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
faker_maker-1.1.2 lib/faker_maker.rb
faker_maker-1.1.1 lib/faker_maker.rb
faker_maker-1.1.0 lib/faker_maker.rb
faker_maker-1.0.1 lib/faker_maker.rb