Module Machinist::Machinable
In: lib/machinist/machinable.rb

Extend classes with this module to define the blueprint and make methods.

Methods

Public Instance methods

Define a blueprint with the given name for this class.

e.g.

  Post.blueprint do
    title { "A Post" }
    body  { "Lorem ipsum..." }
  end

If you provide the name argument, a named blueprint will be created. See the blueprint_name argument to the make method.

Classes that include Machinable can override this method if they want to use a custom blueprint class when constructing blueprints.

The default is Machinist::Blueprint.

Remove all blueprints defined on this class.

Construct an object from a blueprint.

count
The number of objects to construct. If count is provided, make returns an array of objects rather than a single object.
blueprint_name
Construct the object from the named blueprint, rather than the master blueprint.
attributes
Override the attributes from the blueprint with values from this hash.

Construct and save an object from a blueprint, if the class allows saving.

Arguments are the same as for make.

[Validate]