Module: Factrey
- Defined in:
- lib/factrey.rb,
lib/factrey/dsl.rb,
lib/factrey/ref.rb,
lib/factrey/proxy.rb,
lib/factrey/version.rb,
lib/factrey/blueprint.rb,
lib/factrey/ref/defer.rb,
lib/factrey/ref/builder.rb,
lib/factrey/ref/resolver.rb,
lib/factrey/blueprint/node.rb,
lib/factrey/blueprint/type.rb,
lib/factrey/ref/shorthand_methods.rb,
lib/factrey/blueprint/instantiator.rb
Overview
Factrey provides a declarative DSL to represent the creation plan of objects.
Defined Under Namespace
Classes: Blueprint, DSL, Proxy, Ref
Constant Summary collapse
- VERSION =
"0.4.0"
Class Method Summary collapse
-
.blueprint(blueprint = nil, ext: nil, dsl: DSL) { ... } ⇒ Blueprint
Entry point to build or extend a Blueprint.
Class Method Details
.blueprint(blueprint = nil, ext: nil, dsl: DSL) { ... } ⇒ Blueprint
Entry point to build or extend a Blueprint.
36 37 38 39 40 41 42 43 44 45 46 47 |
# File 'lib/factrey.rb', line 36 def blueprint(blueprint = nil, ext: nil, dsl: DSL, &) raise TypeError, "blueprint must be a Blueprint" if blueprint && !blueprint.is_a?(Blueprint) raise TypeError, "dsl must be a subclass of DSL" unless dsl <= DSL is_extending = !blueprint.nil? blueprint ||= Blueprint.new result = block_given? ? dsl.new(blueprint:, ext:).instance_eval(&) : nil blueprint.add_node(Blueprint::Node.computed(Blueprint::Node::RESULT_NAME, result)) unless is_extending blueprint end |