Class: Plumb::Metadata
- Inherits:
-
Object
- Object
- Plumb::Metadata
- Includes:
- Composable
- Defined in:
- lib/plumb/metadata.rb
Instance Attribute Summary collapse
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#==(other) ⇒ Boolean
Metadata nodes include their wrapped type in equality; otherwise unrelated types carrying the same metadata could collapse during subtype reductions.
- #call(result) ⇒ Object
-
#initialize(type, metadata) ⇒ Metadata
constructor
A new instance of Metadata.
-
#input_type ⇒ Object
Metadata is a transparent wrapper: it delegates type-flow to the wrapped type.
- #metadata(data = Undefined) ⇒ Object
- #output_type ⇒ Object
Methods included from Composable
#&, #/, #>>, #[], #absorb_input, #absorb_output, #accepted_type, #as_node, #build, #check, #children, #defer, #fusable_step?, #fuse_with, #generate, #idempotent?, included, #invalid, #invoke, #match, #not, #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(type, metadata) ⇒ Metadata
Returns a new instance of Metadata.
9 10 11 12 13 |
# File 'lib/plumb/metadata.rb', line 9 def initialize(type, ) @type = type @metadata = type..merge() freeze end |
Instance Attribute Details
#type ⇒ Object (readonly)
Returns the value of attribute type.
7 8 9 |
# File 'lib/plumb/metadata.rb', line 7 def type @type end |
Instance Method Details
#==(other) ⇒ Boolean
Metadata nodes include their wrapped type in equality; otherwise unrelated types carrying the same metadata could collapse during subtype reductions.
19 20 21 |
# File 'lib/plumb/metadata.rb', line 19 def ==(other) other.instance_of?(self.class) && type == other.type && @metadata == other. end |
#call(result) ⇒ Object
36 |
# File 'lib/plumb/metadata.rb', line 36 def call(result) = type.call(result) |
#input_type ⇒ Object
Metadata is a transparent wrapper: it delegates type-flow to the wrapped type.
33 |
# File 'lib/plumb/metadata.rb', line 33 def input_type = type.input_type |
#metadata(data = Undefined) ⇒ Object
23 24 25 26 27 28 29 |
# File 'lib/plumb/metadata.rb', line 23 def (data = Undefined) if data == Undefined @metadata else Metadata.new(@type, @metadata.merge(data)) end end |
#output_type ⇒ Object
34 |
# File 'lib/plumb/metadata.rb', line 34 def output_type = type.output_type |