factory_gorl

package module
v0.0.0-...-c5eb5c6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 27, 2015 License: MIT Imports: 3 Imported by: 0

README

factory_gorl

A Go port of Ruby’s factory_girl.

Documentation

Coming soon. In the meantime, take a look at the tests.

Install

go get github.com/gdavison/factory_gorl

Status

So far, it can be used to initialize (Build) an in-memory object and to persist the object (Create) using gorp. Associations have not yet been implemented.

When Createing or Building an object, the factory can be overridden by passing a builder function.

Factory inheritance is implemented.

Copyright © 2014 Graham Davison.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DbMap *gorp.DbMap
)

Functions

func Build

func Build(name string, override Builder) (interface{}, error)

func Create

func Create(name string, override Builder) (interface{}, error)

func RegisterFactory

func RegisterFactory(factory *Factory)

func ResetConfiguration

func ResetConfiguration()

Types

type Builder

type Builder func(i interface{})

type Factory

type Factory struct {
	// contains filtered or unexported fields
}

func FactoryByName

func FactoryByName(name string) (factory *Factory)

func NewFactory

func NewFactory(name string, i interface{}, builder Builder) (*Factory, error)

func NewFactoryWithParent

func NewFactoryWithParent(name string, i interface{}, parent *Factory, builder Builder) (*Factory, error)

func (*Factory) Name

func (factory *Factory) Name() string

func (*Factory) Run

func (factory *Factory) Run(override Builder) interface{}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL