Class: Plumb::ValueClass
- Inherits:
-
Object
- Object
- Plumb::ValueClass
- Includes:
- Composable
- Defined in:
- lib/plumb/value_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) ⇒ ValueClass
constructor
A new instance of ValueClass.
Methods included from Composable
#>>, #as_node, #build, #check, #defer, #generate, included, #invalid, #invoke, #match, #metadata, #not, #pipeline, #policy, #static, #to_json_schema, #to_s, #transform, #value, wrap, #|
Methods included from Callable
Constructor Details
#initialize(value = Undefined) ⇒ ValueClass
Returns a new instance of ValueClass.
11 12 13 14 15 |
# File 'lib/plumb/value_class.rb', line 11 def initialize(value = Undefined) @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/value_class.rb', line 9 def children @children end |
Instance Method Details
#[](value) ⇒ Object
17 |
# File 'lib/plumb/value_class.rb', line 17 def [](value) = self.class.new(value) |
#call(result) ⇒ Object
19 20 21 |
# File 'lib/plumb/value_class.rb', line 19 def call(result) @value == result.value ? result : result.invalid(errors: "Must be equal to #{@value}") end |