class Dao::Entity::Base

Attributes

initialized_with[RW]

Public Class Methods

new(attrs = {}) click to toggle source
Calls superclass method
# File lib/dao/entity/base.rb, line 8
def initialize(attrs = {})
  super
  after_initialize
end

Public Instance Methods

<=>(other) click to toggle source
# File lib/dao/entity/base.rb, line 38
def <=>(other)
  raise ArgumentError, "comparison of #{ self.class.name } with #{ other.class.name } failed" unless other.instance_of?(self.class)
  id <=> other.id
end
==(other) click to toggle source
# File lib/dao/entity/base.rb, line 34
def ==(other)
  other.instance_of?(self.class) && other.identity == identity
end
Also aliased as: eql?
after_initialize() click to toggle source
# File lib/dao/entity/base.rb, line 13
def after_initialize
  @initialized_with = []
end
eql?(other)
Alias for: ==
hash() click to toggle source
# File lib/dao/entity/base.rb, line 30
def hash
  "#{ self.class.name }/#{ identity }".hash
end
initialized_with=(attrs) click to toggle source
# File lib/dao/entity/base.rb, line 17
def initialized_with=(attrs)
  @initialized_with = attrs.presence || []
end
persisted?() click to toggle source
# File lib/dao/entity/base.rb, line 21
def persisted?
  id.present? if respond_to?(:id)
end
to_key() click to toggle source
# File lib/dao/entity/base.rb, line 25
def to_key
  key = respond_to?(:id) && id
  key ? [key] : nil
end

Protected Instance Methods

identity() click to toggle source
# File lib/dao/entity/base.rb, line 47
def identity
  if respond_to?(:id)
    id
  else
    object_id
  end
end