Sha256: a1f1a36261db83582352d9f634b26dd54f562c0335cb27fea32ba5f41db1709e

Contents?: true

Size: 403 Bytes

Versions: 5

Compression:

Stored size: 403 Bytes

Contents

# frozen_string_literal: true

require 'dry/logic/operations/unary'
require 'dry/logic/result'

module Dry
  module Logic
    module Operations
      class Negation < Unary
        def type
          :not
        end

        def call(input)
          Result.new(rule.(input).failure?, id) { ast(input) }
        end

        def [](input)
          !rule[input]
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
dry-logic-1.0.6 lib/dry/logic/operations/negation.rb
dry-logic-1.0.5 lib/dry/logic/operations/negation.rb
dry-logic-1.0.4 lib/dry/logic/operations/negation.rb
dry-logic-1.0.3 lib/dry/logic/operations/negation.rb
dry-logic-1.0.2 lib/dry/logic/operations/negation.rb