Sha256: dfe1e006836d4cb4487a7693ec76146ca6c7ab4368c81eaeaf318154ed1877cd

Contents?: true

Size: 445 Bytes

Versions: 5

Compression:

Stored size: 445 Bytes

Contents

# frozen_string_literal: true

require 'dry/logic/operations/abstract'

module Dry
  module Logic
    module Operations
      class Unary < Abstract
        attr_reader :rule

        def initialize(*rules, **options)
          super
          @rule = rules.first
        end

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

        def to_s
          "#{type}(#{rule})"
        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/unary.rb
dry-logic-1.0.5 lib/dry/logic/operations/unary.rb
dry-logic-1.0.4 lib/dry/logic/operations/unary.rb
dry-logic-1.0.3 lib/dry/logic/operations/unary.rb
dry-logic-1.0.2 lib/dry/logic/operations/unary.rb