Sha256: 104c58581cc0fac5614d03e4d2ff83e1b83f3c9693e8990798044dc5fb815b61

Contents?: true

Size: 857 Bytes

Versions: 7

Compression:

Stored size: 857 Bytes

Contents

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.merge(new_options))
        end

        def with(new_options)
          new(rules, options.merge(new_options))
        end

        def to_ast
          ast
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
dry-logic-1.0.0 lib/dry/logic/operations/abstract.rb
dry-logic-0.6.1 lib/dry/logic/operations/abstract.rb
dry-logic-0.6.0 lib/dry/logic/operations/abstract.rb
dry-logic-0.5.0 lib/dry/logic/operations/abstract.rb
dry-logic-0.4.2 lib/dry/logic/operations/abstract.rb
dry-logic-0.4.1 lib/dry/logic/operations/abstract.rb
dry-logic-0.4.0 lib/dry/logic/operations/abstract.rb