Sha256: 6beacb216adc648d7e4ddca09f496f17b2f6761ab39ab4e8e97134b5b5cade10

Contents?: true

Size: 842 Bytes

Versions: 6

Compression:

Stored size: 842 Bytes

Contents

# frozen_string_literal: true

#
# Copyright (c) 2019-present, Blue Marble Payroll, LLC
#
# This source code is licensed under the MIT license found in the
# LICENSE file in the root directory of this source tree.
#

module Dbee
  class Query
    class Filters
      # Defines the shared implementation for all filters.
      class Base
        acts_as_hashable

        attr_reader :key_path, :value

        def initialize(key_path:, value: nil)
          raise ArgumentError, 'key_path is required' if key_path.to_s.empty?

          @key_path = KeyPath.get(key_path)
          @value    = value

          freeze
        end

        def hash
          "#{key_path}#{value}".hash
        end

        def ==(other)
          other.key_path == key_path && other.value == value
        end
        alias eql? ==
      end
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
dbee-1.0.1 lib/dbee/query/filters/base.rb
dbee-1.0.0 lib/dbee/query/filters/base.rb
dbee-1.0.0.pre.alpha.3 lib/dbee/query/filters/base.rb
dbee-1.0.0.pre.alpha.2 lib/dbee/query/filters/base.rb
dbee-1.0.0.pre.alpha.1 lib/dbee/query/filters/base.rb
dbee-1.0.0.pre.alpha lib/dbee/query/filters/base.rb