Class: Dbee::Model::Constraints::Base
- Inherits:
-
Object
- Object
- Dbee::Model::Constraints::Base
- Defined in:
- lib/dbee/model/constraints/base.rb
Overview
Base class for all constraints.
Instance Attribute Summary collapse
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#parent ⇒ Object
readonly
Returns the value of attribute parent.
Instance Method Summary collapse
- #<=>(other) ⇒ Object
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(name: '', parent: '') ⇒ Base
constructor
A new instance of Base.
Constructor Details
#initialize(name: '', parent: '') ⇒ Base
Returns a new instance of Base.
19 20 21 22 |
# File 'lib/dbee/model/constraints/base.rb', line 19 def initialize(name: '', parent: '') @name = name.to_s @parent = parent.to_s end |
Instance Attribute Details
#name ⇒ Object (readonly)
Returns the value of attribute name.
17 18 19 |
# File 'lib/dbee/model/constraints/base.rb', line 17 def name @name end |
#parent ⇒ Object (readonly)
Returns the value of attribute parent.
17 18 19 |
# File 'lib/dbee/model/constraints/base.rb', line 17 def parent @parent end |
Instance Method Details
#<=>(other) ⇒ Object
24 25 26 |
# File 'lib/dbee/model/constraints/base.rb', line 24 def <=>(other) "#{self.class.name}#{name}#{parent}" <=> "#{other.class.name}#{other.name}#{other.parent}" end |
#==(other) ⇒ Object Also known as: eql?
32 33 34 35 36 |
# File 'lib/dbee/model/constraints/base.rb', line 32 def ==(other) other.instance_of?(self.class) && other.name == name && other.parent == parent end |
#hash ⇒ Object
28 29 30 |
# File 'lib/dbee/model/constraints/base.rb', line 28 def hash "#{self.class.name}#{name}#{parent}".hash end |