Module: Pad::Entity
- Defined in:
- lib/pad/entity.rb
Class Method Summary collapse
Instance Method Summary collapse
- #==(other) ⇒ Object
- #cmp?(comparator, other) ⇒ Boolean private
- #eql?(other) ⇒ Boolean
- #hash ⇒ Object
Class Method Details
.included(base) ⇒ Object
3 4 5 6 7 |
# File 'lib/pad/entity.rb', line 3 def self.included(base) base.instance_eval do attribute :id end end |
Instance Method Details
#==(other) ⇒ Object
9 10 11 |
# File 'lib/pad/entity.rb', line 9 def ==(other) cmp?(__method__, other) end |
#cmp?(comparator, other) ⇒ Boolean
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
22 23 24 25 26 27 28 29 30 |
# File 'lib/pad/entity.rb', line 22 def cmp?(comparator, other) return false unless other.class == self.class if id.nil? equal?(other) else id.send(comparator, other.id) end end |
#eql?(other) ⇒ Boolean
13 14 15 |
# File 'lib/pad/entity.rb', line 13 def eql?(other) cmp?(__method__, other) end |
#hash ⇒ Object
17 18 19 |
# File 'lib/pad/entity.rb', line 17 def hash [self.class, id].hash end |