Class: SirTracksAlot::Persistable
- Inherits:
-
Ohm::Model
- Object
- Ohm::Model
- SirTracksAlot::Persistable
- Defined in:
- lib/sir_tracks_alot/persistable.rb
Direct Known Subclasses
Activity, Count, Queue::ReportCache, Queue::ReportConfig, Queue::ReportQueue, Summary
Class Method Summary collapse
Instance Method Summary collapse
-
#==(comparee) ⇒ Object
Objects are equal if they have the same unique custom identifier.
-
#eql?(comparee) ⇒ Boolean
Simply delegate to == in this example.
- #hash ⇒ Object
- #to_hash ⇒ Object
Class Method Details
.find_or_create(attributes) ⇒ Object
7 8 9 10 |
# File 'lib/sir_tracks_alot/persistable.rb', line 7 def self.find_or_create(attributes) models = self.find(attributes) models.empty? ? self.create(attributes.merge(:created_at => Clock.now)) : models.first end |
Instance Method Details
#==(comparee) ⇒ Object
Objects are equal if they have the same unique custom identifier.
23 24 25 |
# File 'lib/sir_tracks_alot/persistable.rb', line 23 def ==(comparee) self.id == comparee.id end |
#eql?(comparee) ⇒ Boolean
Simply delegate to == in this example.
17 18 19 |
# File 'lib/sir_tracks_alot/persistable.rb', line 17 def eql?(comparee) self == comparee end |
#hash ⇒ Object
12 13 14 |
# File 'lib/sir_tracks_alot/persistable.rb', line 12 def hash self.id end |
#to_hash ⇒ Object
27 28 29 |
# File 'lib/sir_tracks_alot/persistable.rb', line 27 def to_hash super end |