Class: Plumb::Not
Instance Attribute Summary collapse
-
#children ⇒ Object
readonly
Returns the value of attribute children.
-
#errors ⇒ Object
readonly
Returns the value of attribute errors.
Instance Method Summary collapse
- #[](step) ⇒ Not
- #call(result) ⇒ Object
-
#initialize(step = nil, errors: nil) ⇒ Not
constructor
A new instance of Not.
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(step = nil, errors: nil) ⇒ Not
Returns a new instance of Not.
11 12 13 14 15 16 |
# File 'lib/plumb/not.rb', line 11 def initialize(step = nil, errors: nil) @step = Composable.wrap(step) @errors = errors || "must not be #{step.inspect}" @children = [step].freeze freeze end |
Instance Attribute Details
#children ⇒ Object (readonly)
Returns the value of attribute children.
9 10 11 |
# File 'lib/plumb/not.rb', line 9 def children @children end |
#errors ⇒ Object (readonly)
Returns the value of attribute errors.
9 10 11 |
# File 'lib/plumb/not.rb', line 9 def errors @errors end |
Instance Method Details
#call(result) ⇒ Object
28 29 30 31 |
# File 'lib/plumb/not.rb', line 28 def call(result) result = @step.call(result) result.valid? ? result.invalid(errors: @errors) : result.valid end |