Sequel::Factory implements a tiny DSL on Sequel::Model that allows you to create factories for objects of a model class. A factory is simply a Ruby block that gets evaluated each time a new object is generated. Inside the block you can call methods that correspond to the names of attributes of the object you're creating. If a value is given to the method, it will set the value for that attribute. Regardless, the method will always return the current value for that attribute.
Factories have names (the default name is :default
) and you can include a factory in another. When you do this, the included factory will run first.
A simple factory for a User
class might look like this:
User.factory do