Sha256: 8141e604fc8afc18c94eba9f5d27b2e140ff57cd66a16672e7d35003846682c4

Contents?: true

Size: 886 Bytes

Versions: 3

Compression:

Stored size: 886 Bytes

Contents

# frozen_string_literal: true

require 'dry/core/constants'
require 'dry/equalizer'
require 'dry/logic/operators'

module Dry
  module Logic
    module Operations
      class Abstract
        include Core::Constants
        include Dry::Equalizer(:rules, :options)
        include Operators

        attr_reader :rules

        attr_reader :options

        def initialize(*rules, **options)
          @rules = rules
          @options = options
        end

        def id
          options[:id]
        end

        def curry(*args)
          new(rules.map { |rule| rule.curry(*args) }, **options)
        end

        def new(rules, **new_options)
          self.class.new(*rules, **options, **new_options)
        end

        def with(new_options)
          new(rules, **options, **new_options)
        end

        def to_ast
          ast
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
dry-logic-1.0.6 lib/dry/logic/operations/abstract.rb
dry-logic-1.0.5 lib/dry/logic/operations/abstract.rb
dry-logic-1.0.4 lib/dry/logic/operations/abstract.rb