ORM::Factory
Every page of the ORM::Factory manual, in reading order.
- Overview The latest version of this documentation lives at https://gdonald.github.io/ORM-Factory/.
- Getting started This page walks you through defining your first factory, reading it back from the registry, and resetting state between tests.
- DSL design ORM::Factory's DSL needs to capture arbitrary attribute names inside a block without pre-declaring them. Raku's identifier resolution is lexical and...
- Bare-name DSL ORM::Factory::DSL is an opt-in module that defines factories without the leading-dot method-call syntax. It is plain Raku (exported subs over a dynamic...
- Methods syntax use ORM::Factory exports plain-sub wrappers around every public factory method, so specs can stay terse:
- Aliases A factory can register one or more aliases — alternative names that look up the same definition. Aliases also drive the implicit-association lookup (see...
- Class resolution Every factory needs a class to instantiate. ORM::Factory tries to infer it from the factory name, but you can override the inference explicitly, or...
- Overrides Every build method — build, create, attributes-for, build-stubbed, and their -list / -pair cousins — accepts named arguments that override attributes for...
- Dependent attributes An attribute defined as a block can reference any other attribute on the factory by calling it as a method on the evaluator. The evaluator is bound to $_...
- Transient attributes A *transient* attribute is visible inside the factory (to dynamic blocks, overrides, and callbacks) but is not passed to the model constructor and is not...
- Sequences A *sequence* is a named counter that yields a new value on every call. Use sequences when you want unique attribute values across factory builds — emails,...
- Associations An *association* binds an attribute on one factory to an instance built by another. ORM::Factory resolves associations lazily at build time, so the...
- Inheritance A factory can derive from another factory, picking up its attributes, transients, and variants while adding or overriding pieces of its own. The parent's...
- Variants A variant captures a named cluster of attribute, association, or transient changes that you can layer onto a factory on demand.
- Build strategies ORM::Factory ships four strategies for turning a factory definition into a result. They all share the same surface — (Str:D $name, *@variants,...
- Strategies A *strategy* is the object that decides what build, create, attributes-for, and build-stubbed actually do. Each public method on ORM::Factory is a thin...
- Collections Each of the core build strategies has a -list form that produces N instances, plus a -pair shortcut for two. The same variant, override, and block-form...
- Construction ORM::Factory is ORM-agnostic at its core — every build strategy routes instantiation and persistence through the Persistence adapter. Three hooks override...
- Custom strategies ORM::Factory ships with four built-in strategies (build, create, attributes-for, build-stubbed). You can register your own at runtime — or replace a...
- Callbacks Callbacks hook into the build lifecycle so a factory can mutate its instance or trigger side-effects at well-defined points. The built-in events are after...
- Persistence ORM::Factory is ORM-agnostic at its core. The build strategies (build, create, attributes-for, build-stubbed) target a small protocol —...
- ORM::ActiveRecord adapter ORM::Factory ships with a concrete adapter for ORM::ActiveRecord. It is auto-detected on first use: if ORM::ActiveRecord::Model is loadable in the...
- Configuration ORM::Factory.configure is the single entry point for project-wide knobs. It accepts a builder block; the receiver exposes setters for every supported...
- Linting & diagnostics ORM::Factory.lint builds every registered factory through a chosen strategy and aggregates the failures. It is the simplest way to confirm a suite of...
- Concurrency ORM::Factory's registry, sequences, and build pipeline are designed for concurrent use. The guarantees here are explicit; assumptions outside this page...
- Performance build-stubbed exists specifically to avoid the database; that advantage should be real and stay real across releases.
- Cookbook Common recipes for ORM::Factory, each self-contained.
- Tests ORM::Factory ships a parallel t/ and specs/ tree. Both contain the same coverage; t/ is the canonical prove6 suite (kept while ecosystem tooling still...