Sha256: c09000b4961616e3afb7db81624b9a5dab4b1726f2d1a761729e3f6b6a6194e0

Contents?: true

Size: 520 Bytes

Versions: 4

Compression:

Stored size: 520 Bytes

Contents

# frozen_string_literal: true

require "dry/logic/operations/abstract"

module Dry
  module Logic
    module Operations
      class Binary < Abstract
        attr_reader :left

        attr_reader :right

        def initialize(*rules, **options)
          super
          @left, @right = rules
        end

        def ast(input = Undefined)
          [type, [left.ast(input), right.ast(input)]]
        end

        def to_s
          "#{left} #{operator.to_s.upcase} #{right}"
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
dry-logic-1.1.0 lib/dry/logic/operations/binary.rb
dry-logic-1.0.8 lib/dry/logic/operations/binary.rb
grape-extra_validators-2.0.0 vendor/bundle/ruby/2.6.0/gems/dry-logic-1.0.7/lib/dry/logic/operations/binary.rb
dry-logic-1.0.7 lib/dry/logic/operations/binary.rb