Class: Plumb::Not

Inherits:
Object
  • Object
show all
Includes:
Composable
Defined in:
lib/plumb/not.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#parse, #resolve

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

#childrenObject (readonly)

Returns the value of attribute children.



9
10
11
# File 'lib/plumb/not.rb', line 9

def children
  @children
end

#errorsObject (readonly)

Returns the value of attribute errors.



9
10
11
# File 'lib/plumb/not.rb', line 9

def errors
  @errors
end

Instance Method Details

#[](step) ⇒ Not

Parameters:

  • step (Object)

Returns:



20
21
22
# File 'lib/plumb/not.rb', line 20

def [](step)
  self.class.new(step)
end

#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