class Dry::Logic::Operations::And

Attributes

hints[R]

Public Class Methods

new(*, **) click to toggle source
Calls superclass method
# File lib/dry/logic/operations/and.rb, line 12
def initialize(*, **)
  super
  @hints = options.fetch(:hints, true)
end

Public Instance Methods

[](input) click to toggle source
# File lib/dry/logic/operations/and.rb, line 41
def [](input)
  left[input] && right[input]
end
call(input) click to toggle source
# File lib/dry/logic/operations/and.rb, line 22
def call(input)
  left_result = left.(input)

  if left_result.success?
    right_result = right.(input)

    if right_result.success?
      Result::SUCCESS
    else
      Result.new(false, id) { right_result.ast(input) }
    end
  else
    Result.new(false, id) do
      left_ast = left_result.to_ast
      hints ? [type, [left_ast, [:hint, right.ast(input)]]] : left_ast
    end
  end
end
operator()
Alias for: type
type() click to toggle source
# File lib/dry/logic/operations/and.rb, line 17
def type
  :and
end
Also aliased as: operator