Module: ObjectForge
- Defined in:
- lib/object_forge.rb,
lib/object_forge/forge.rb,
lib/object_forge/molds.rb,
lib/object_forge/version.rb,
lib/object_forge/crucible.rb,
lib/object_forge/sequence.rb,
lib/object_forge/forge_dsl.rb,
lib/object_forge/forgeyard.rb,
lib/object_forge/molds/hash_mold.rb,
lib/object_forge/molds/mold_mold.rb,
lib/object_forge/un_basic_object.rb,
lib/object_forge/molds/struct_mold.rb,
lib/object_forge/molds/wrapped_mold.rb,
lib/object_forge/molds/keywords_mold.rb,
lib/object_forge/molds/single_argument_mold.rb
Overview
A simple all-purpose factory library with minimal assumptions.
These are the main classes you should be aware of:
-
Forgeyard is a registry of named related Forges. A Forgeyard allows to Forgeyard#define a Forge, and Forgeyard#forge a new object using a defined Forge.
-
Forge is a factory for objects. Usually created through Forgeyard#define/Forge.define in a manner similar to FactoryBot, Forges can be used standalone, or as a part of a Forgeyard.
-
Sequence is a representation of a sequence of values. They are usually used implicitly through ForgeDSL#sequence, but can be created explicitly to be shared (or used outside of ObjectForge).
Additionally, successful use may depend on understanding these:
Defined Under Namespace
Modules: Molds Classes: Crucible, DSLError, Error, Forge, ForgeDSL, Forgeyard, Sequence, UnBasicObject
Constant Summary collapse
- DEFAULT_YARD =
Forgeyard.new
- VERSION =
Current version
"0.2.0"
Class Method Summary collapse
-
.define(name, forged, &) ⇒ Forge
Define and create a forge in DEFAULT_YARD.
-
.forge(name, *traits, **overrides, &) ⇒ Any
(also: build, [])
Build an instance using a forge from DEFAULT_YARD.
-
.sequence(initial) ⇒ Sequence
Create a sequence, to be used wherever it needs to be.
Class Method Details
.define(name, forged, &) ⇒ Forge
Default forgeyard is intended to be useful for non-shareable code, like simple application tests and specs. It should not be used in application code, and never in gems.
Define and create a forge in DEFAULT_YARD.
85 86 87 |
# File 'lib/object_forge.rb', line 85 def self.define(...) DEFAULT_YARD.define(...) end |
.forge(name, *traits, **overrides, &) ⇒ Any Also known as: build, []
Default forgeyard is intended to be useful for non-shareable code, like simple application tests and specs. It should not be used in application code, and never in gems.
Build an instance using a forge from DEFAULT_YARD.
102 103 104 |
# File 'lib/object_forge.rb', line 102 def self.forge(...) DEFAULT_YARD.forge(...) end |
.sequence(initial) ⇒ Sequence
Create a sequence, to be used wherever it needs to be.
69 70 71 |
# File 'lib/object_forge.rb', line 69 def self.sequence(...) Sequence.new(...) end |