Class: Perpetuity::Reference

Inherits:
Object
  • Object
show all
Defined in:
lib/perpetuity/reference.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#idObject (readonly)

Returns the value of attribute id.



3
4
5
# File 'lib/perpetuity/reference.rb', line 3

def id
  @id
end

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

Returns:

  • (Boolean)


17
18
19
# File 'lib/perpetuity/reference.rb', line 17

def eql? other
  other.is_a?(self.class) && self == other
end