Sha256: 4b35cd309644f82a387c0f455998851bffe0795a0ded0b9b85274239320d24d4

Contents?: true

Size: 859 Bytes

Versions: 7

Compression:

Stored size: 859 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.
#

require_relative 'base'

module Dbee
  class Model
    class Constraints
      # A static constraint is a equality constraint on a child column to a static value.
      # It is usually used in conjunction with a ReferenceConstraint, further giving it more
      # scoping.
      class Static < Base
        attr_reader :value

        def initialize(name:, value: nil)
          super(name: name)

          @value = value

          freeze
        end

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

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

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
dbee-1.0.2 lib/dbee/model/constraints/static.rb
dbee-1.0.1 lib/dbee/model/constraints/static.rb
dbee-1.0.0 lib/dbee/model/constraints/static.rb
dbee-1.0.0.pre.alpha.3 lib/dbee/model/constraints/static.rb
dbee-1.0.0.pre.alpha.2 lib/dbee/model/constraints/static.rb
dbee-1.0.0.pre.alpha.1 lib/dbee/model/constraints/static.rb
dbee-1.0.0.pre.alpha lib/dbee/model/constraints/static.rb