Class: Plumb::Union

Inherits:
Object
  • Object
show all
Includes:
Composable, Disjunction
Defined in:
lib/plumb/union.rb

Overview

THE LATTICE JOIN — the least upper bound of two types, dual to Intersection. Built by #| when every branch returns its value untouched, so the node describes exactly "a value in either set" and is its own output type. That is the difference from Or, whose ends differ.

Instance Attribute Summary

Attributes included from Disjunction

#children

Instance Method Summary collapse

Methods included from Disjunction

build, #call, #initialize, #input_type, merge_errors, #with_children

Methods included from Composable

#&, #/, #>>, #[], #absorb_input, #absorb_output, #accepted_type, #as_node, #build, #check, #children, #defer, #fusable_step?, #fuse_with, #generate, #idempotent?, included, #input_type, #invalid, #invoke, #match, #metadata, #not, #pipeline, #policy, resolve_operand, #static, #subtype_identity, #to_json_schema, #to_mermaid, #to_plumb_type, #to_s, #transform, #value, #where, #with, wrap, #|

Methods included from Callable

#call, #parse, #resolve

Instance Method Details

#output_typeObject

No lazy rebuild, no identity guard, no allocation — the mapping Or needs exists only because a converting branch makes its ends differ.

NOT symmetric with #input_type, which is inherited from Disjunction: a branch may accept more than it describes, so the input side still has to map.



20
# File 'lib/plumb/union.rb', line 20

def output_type = self

#value_preserving?Boolean

An invariant of the node: Disjunction.build only produces a Union when every branch preserves the value. @see Intersection#value_preserving?

Returns:

  • (Boolean)


24
# File 'lib/plumb/union.rb', line 24

def value_preserving? = true