Composable¶
composable
¶
Composable specification abstraction.
Adds fluent logical composition to the core Specification contract.
Operators are defined ONCE here and delegate to logical classes.
Subclasses inherit them automatically—no reimplementation needed.
The logical operator classes (AndSpecification, OrSpecification,
NotSpecification) themselves inherit from ComposableSpecification so
that the result of a composition is itself composable. Because the operators
depend on this class for their base while this class delegates back to the
operators, importing the operators at module level would create a circular
import. The operator imports are therefore deferred into the methods that
construct them, keeping the static import graph acyclic:
composable -> base and logical_operators -> composable -> base.
ComposableSpecification
¶
Bases: Specification[T]
Specification supporting fluent logical composition.
Provides a single definition of composition operators:
- and_() / and() → delegates to AndSpecification
- or_() / or() → delegates to OrSpecification
- not_() / invert() → delegates to NotSpecification
Subclasses inherit these automatically. Do NOT reimplement in subclasses.
Source code in src/forging_blocks/foundation/specification/composable.py
and_(other: Specification[T]) -> Specification[T]
¶
Combine two specifications using logical conjunction.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other
|
Specification[T]
|
The specification to AND with this one. |
required |
Returns:
| Type | Description |
|---|---|
Specification[T]
|
A new AndSpecification combining both. |
Source code in src/forging_blocks/foundation/specification/composable.py
or_(other: Specification[T]) -> Specification[T]
¶
Combine two specifications using logical disjunction.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other
|
Specification[T]
|
The specification to OR with this one. |
required |
Returns:
| Type | Description |
|---|---|
Specification[T]
|
A new OrSpecification combining both. |
Source code in src/forging_blocks/foundation/specification/composable.py
not_() -> Specification[T]
¶
Create the logical negation of this specification.
Returns:
| Type | Description |
|---|---|
Specification[T]
|
A new NotSpecification wrapping this one. |
Source code in src/forging_blocks/foundation/specification/composable.py
__and__(other: Specification[T]) -> Specification[T]
¶
Operator overload for & (bitwise AND).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other
|
Specification[T]
|
The specification to AND with this one. |
required |
Returns:
| Type | Description |
|---|---|
Specification[T]
|
A new AndSpecification combining both. |
Source code in src/forging_blocks/foundation/specification/composable.py
__or__(other: Specification[T]) -> Specification[T]
¶
Operator overload for | (bitwise OR).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
other
|
Specification[T]
|
The specification to OR with this one. |
required |
Returns:
| Type | Description |
|---|---|
Specification[T]
|
A new OrSpecification combining both. |
Source code in src/forging_blocks/foundation/specification/composable.py
__invert__() -> Specification[T]
¶
Operator overload for ~ (bitwise NOT).
Returns:
| Type | Description |
|---|---|
Specification[T]
|
A new NotSpecification wrapping this one. |