Sha256: dec391eeddc698e2265e363d4eb7e9d334d8583307df33f35cf940c1bd1c931e

Contents?: true

Size: 1.03 KB

Versions: 14

Compression:

Stored size: 1.03 KB

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 and/or parent 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: '', parent: '', value: nil)
          if name.to_s.empty? && parent.to_s.empty?
            raise ArgumentError, "name (#{name}) and/or parent (#{parent}) required"
          end

          super(name: name, parent: parent)

          @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

14 entries across 14 versions & 1 rubygems

Version Path
dbee-3.1.0 lib/dbee/model/constraints/static.rb
dbee-3.0.0 lib/dbee/model/constraints/static.rb
dbee-2.1.1 lib/dbee/model/constraints/static.rb
dbee-2.1.0 lib/dbee/model/constraints/static.rb
dbee-2.1.0.pre.alpha lib/dbee/model/constraints/static.rb
dbee-2.0.3 lib/dbee/model/constraints/static.rb
dbee-2.0.2 lib/dbee/model/constraints/static.rb
dbee-2.0.1 lib/dbee/model/constraints/static.rb
dbee-2.0.0 lib/dbee/model/constraints/static.rb
dbee-2.0.0.pre.alpha lib/dbee/model/constraints/static.rb
dbee-1.2.1 lib/dbee/model/constraints/static.rb
dbee-1.2.0 lib/dbee/model/constraints/static.rb
dbee-1.1.0 lib/dbee/model/constraints/static.rb
dbee-1.0.3 lib/dbee/model/constraints/static.rb