Module: NCore::Identity

Extended by:
ActiveSupport::Concern
Defined in:
lib/ncore/identity.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#==(comparison_object) ⇒ Object Also known as: eql?

from ActiveRecord::Core



31
32
33
34
35
36
# File 'lib/ncore/identity.rb', line 31

def ==(comparison_object)
  super ||
    comparison_object.instance_of?(self.class) &&
    !id.nil? &&
    comparison_object.id == id
end

#hashObject



39
40
41
42
43
44
45
# File 'lib/ncore/identity.rb', line 39

def hash
  if id
    self.class.hash ^ id.hash
  else
    super
  end
end

#json_rootObject



47
48
49
# File 'lib/ncore/identity.rb', line 47

def json_root
  self.class.json_root
end

#to_sObject



51
52
53
# File 'lib/ncore/identity.rb', line 51

def to_s
  "#{self.class.name}(id=#{id})"
end