Module: Lafcadio::DomainComparable
- Includes:
- Comparable
- Included in:
- DomainObject, DomainObjectProxy
- Defined in:
- lib/lafcadio/domain.rb
Overview
DomainComparable is used by DomainObject and DomainObjectProxy to define comparisons.
Instance Method Summary collapse
-
#<=>(anOther) ⇒ Object
A DomainObject or DomainObjectProxy is compared by
domain_class
and bypk_id
. -
#eql?(otherObj) ⇒ Boolean
Two DomainObjects or DomainObjectProxies are eql? if they have the same
domain_class
and the samepk_id
. - #hash ⇒ Object
Instance Method Details
#<=>(anOther) ⇒ Object
A DomainObject or DomainObjectProxy is compared by domain_class
and by pk_id
.
124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/lafcadio/domain.rb', line 124 def <=>(anOther) if anOther.respond_to?( 'domain_class' ) if self.domain_class == anOther.domain_class self.pk_id <=> anOther.pk_id else self.domain_class.name <=> anOther.domain_class.name end else nil end end |
#eql?(otherObj) ⇒ Boolean
Two DomainObjects or DomainObjectProxies are eql? if they have the same domain_class
and the same pk_id
.
138 |
# File 'lib/lafcadio/domain.rb', line 138 def eql?( otherObj ); self == otherObj; end |
#hash ⇒ Object
140 |
# File 'lib/lafcadio/domain.rb', line 140 def hash; "#{ self.class.name } #{ pk_id }".hash; end |