class Dbee::Model::Constraints::Static

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.

Attributes

value[R]

Public Class Methods

new(name: '', parent: '', value: nil) click to toggle source
Calls superclass method Dbee::Model::Constraints::Base::new
# File lib/dbee/model/constraints/static.rb, line 21
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

Public Instance Methods

==(other) click to toggle source
Calls superclass method Dbee::Model::Constraints::Base#==
# File lib/dbee/model/constraints/static.rb, line 37
def ==(other)
  super && other.value == value
end
Also aliased as: eql?
eql?(other)
Alias for: ==
hash() click to toggle source
# File lib/dbee/model/constraints/static.rb, line 33
def hash
  "#{super}#{value}".hash
end