Class: Dbee::Model::Constraints::Static
- Defined in:
- lib/dbee/model/constraints/static.rb
Overview
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.
Instance Attribute Summary collapse
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Attributes inherited from Base
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(name: '', parent: '', value: nil) ⇒ Static
constructor
A new instance of Static.
Methods inherited from Base
Constructor Details
#initialize(name: '', parent: '', value: nil) ⇒ Static
Returns a new instance of Static.
21 22 23 24 25 26 27 28 29 30 31 |
# 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 |
Instance Attribute Details
#value ⇒ Object (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?
37 38 39 |
# File 'lib/dbee/model/constraints/static.rb', line 37 def ==(other) super && other.value == value end |
#hash ⇒ Object
33 34 35 |
# File 'lib/dbee/model/constraints/static.rb', line 33 def hash "#{super}#{value}".hash end |