Class: Dbee::Model::Constraints::Static

Inherits:
Base
  • Object
show all
Defined in:
lib/dbee/model/constraints/static.rb

Overview

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.

Instance Attribute Summary collapse

Attributes inherited from Base

#name

Instance Method Summary collapse

Constructor Details

#initialize(name:, value: nil) ⇒ Static

Returns a new instance of Static.



21
22
23
24
25
26
27
# File 'lib/dbee/model/constraints/static.rb', line 21

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

  @value = value

  freeze
end

Instance Attribute Details

#valueObject (readonly)

Returns the value of attribute value.



19
20
21
# File 'lib/dbee/model/constraints/static.rb', line 19

def value
  @value
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



33
34
35
# File 'lib/dbee/model/constraints/static.rb', line 33

def ==(other)
  super && other.value == value
end

#hashObject



29
30
31
# File 'lib/dbee/model/constraints/static.rb', line 29

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