Class: Perpetuity::Reference
- Inherits:
-
Object
- Object
- Perpetuity::Reference
- Defined in:
- lib/perpetuity/reference.rb
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#klass ⇒ Object
readonly
Returns the value of attribute klass.
Instance Method Summary collapse
- #==(other) ⇒ Object
- #eql?(other) ⇒ Boolean
-
#initialize(klass, id) ⇒ Reference
constructor
A new instance of Reference.
Constructor Details
#initialize(klass, id) ⇒ Reference
Returns a new instance of Reference.
4 5 6 7 |
# File 'lib/perpetuity/reference.rb', line 4 def initialize klass, id @klass = klass @id = id end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
3 4 5 |
# File 'lib/perpetuity/reference.rb', line 3 def id @id end |
#klass ⇒ Object (readonly)
Returns the value of attribute klass.
3 4 5 |
# File 'lib/perpetuity/reference.rb', line 3 def klass @klass end |
Instance Method Details
#==(other) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/perpetuity/reference.rb', line 9 def == other if other.is_a? self.class klass == other.klass && id == other.id else other.is_a?(klass) && id == other.instance_variable_get(:@id) end end |
#eql?(other) ⇒ Boolean
17 18 19 |
# File 'lib/perpetuity/reference.rb', line 17 def eql? other other.is_a?(self.class) && self == other end |