Class: Plumb::StaticClass
- Inherits:
-
Object
- Object
- Plumb::StaticClass
- Includes:
- Composable
- Defined in:
- lib/plumb/static_class.rb
Instance Attribute Summary collapse
-
#children ⇒ Object
readonly
Returns the value of attribute children.
Instance Method Summary collapse
- #[](value) ⇒ Object
- #call(result) ⇒ Object
-
#initialize(value = Undefined) ⇒ StaticClass
constructor
A new instance of StaticClass.
-
#input_type ⇒ Object
A static step ignores its input and always emits a fixed value.
-
#subtype_of?(other) ⇒ Boolean
Tests the concrete produced value directly.
Methods included from Composable
#&, #/, #>>, #absorb_input, #absorb_output, #accepted_type, #as_node, #build, #check, #defer, #fusable_step?, #fuse_with, #generate, #idempotent?, included, #invalid, #invoke, #match, #metadata, #not, #output_type, #pipeline, #policy, resolve_operand, #static, #subtype_identity, #to_json_schema, #to_mermaid, #to_plumb_type, #to_s, #transform, #value, #value_preserving?, #where, #with, wrap, #|
Methods included from Callable
Constructor Details
#initialize(value = Undefined) ⇒ StaticClass
Returns a new instance of StaticClass.
11 12 13 14 15 16 17 |
# File 'lib/plumb/static_class.rb', line 11 def initialize(value = Undefined) raise ArgumentError, 'value must be frozen' unless value.frozen? @value = value @children = [value].freeze freeze end |
Instance Attribute Details
#children ⇒ Object (readonly)
Returns the value of attribute children.
9 10 11 |
# File 'lib/plumb/static_class.rb', line 9 def children @children end |
Instance Method Details
#[](value) ⇒ Object
19 20 21 |
# File 'lib/plumb/static_class.rb', line 19 def [](value) self.class.new(value) end |
#call(result) ⇒ Object
42 43 44 |
# File 'lib/plumb/static_class.rb', line 42 def call(result) result.valid!(@value) end |
#input_type ⇒ Object
A static step ignores its input and always emits a fixed value. Its input
is therefore Any — it accepts anything, so it opts out of #>> checks on
the input side (eg. as the right of Undefined >> Static[x]). Its output
is the value itself (the default #output_type — this atomic node wraps
the value), so a successor that could never accept that value is caught
at composition time, eg. Types::Static['foo'] >> Types::Integer raises.
29 |
# File 'lib/plumb/static_class.rb', line 29 def input_type = Types::Any |
#subtype_of?(other) ⇒ Boolean
Tests the concrete produced value directly. Atomic matcher logic is unsuitable here because it models matched values and widens numeric equality domains.
35 36 37 38 39 40 |
# File 'lib/plumb/static_class.rb', line 35 def subtype_of?(other) return true if self == other return super if @value.is_a?(Composable) other === @value end |