Class: Dbee::Model::Constraints::Base

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

Overview

Base class for all constraints.

Direct Known Subclasses

Reference, Static

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#nameObject (readonly)

Returns the value of attribute name.



17
18
19
# File 'lib/dbee/model/constraints/base.rb', line 17

def name
  @name
end

#parentObject (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

#hashObject



28
29
30
# File 'lib/dbee/model/constraints/base.rb', line 28

def hash
  "#{self.class.name}#{name}#{parent}".hash
end