Class: SirTracksAlot::Activity
- Inherits:
-
Persistable
- Object
- Ohm::Model
- Persistable
- SirTracksAlot::Activity
- Extended by:
- FilterHelper
- Includes:
- EventHelper
- Defined in:
- lib/sir_tracks_alot/activity.rb
Constant Summary collapse
- ACTIONS =
[:create, :view, :login, :search, :update, :destroy]
Constants included from EventHelper
Class Method Summary collapse
-
.create(attrs) ⇒ Object
Create with defaults: counted = 0.
- .ohm_create ⇒ Object
-
.purge!(options_for_find = {}, options_for_sort = {:order => 'DESC', :start => 500, :limit => 500}) ⇒ Object
Delete 500 counted activities, leaving a default of the 500 most recent for the provided search criteria.
-
.recent(options_for_find, options_for_sort = {:order => 'DESC', :limit => 500}) ⇒ Object
find recent activities.
Instance Method Summary collapse
-
#counted! ⇒ Object
set this activity to counted and clear the recorded events.
-
#counted? ⇒ Boolean
is this activity counted?.
Methods included from FilterHelper
extract_filter_options, filter
Methods included from EventHelper
Methods inherited from Persistable
#==, #eql?, find_or_create, #hash, #to_hash
Class Method Details
.create(attrs) ⇒ Object
Create with defaults: counted = 0
32 33 34 |
# File 'lib/sir_tracks_alot/activity.rb', line 32 def create(attrs) ohm_create(attrs.merge(:counted => '0')) end |
.ohm_create ⇒ Object
29 |
# File 'lib/sir_tracks_alot/activity.rb', line 29 alias_method :ohm_create, :create |
.purge!(options_for_find = {}, options_for_sort = {:order => 'DESC', :start => 500, :limit => 500}) ⇒ Object
Delete 500 counted activities, leaving a default of the 500 most recent for the provided search criteria
43 44 45 |
# File 'lib/sir_tracks_alot/activity.rb', line 43 def self.purge!( = {}, = {:order => 'DESC', :start => 500, :limit => 500}) recent(.merge(:counted => 1), ).each{|a| a.delete} end |
.recent(options_for_find, options_for_sort = {:order => 'DESC', :limit => 500}) ⇒ Object
find recent activities
38 39 40 |
# File 'lib/sir_tracks_alot/activity.rb', line 38 def self.recent(, = {:order => 'DESC', :limit => 500}) find().sort_by(:last_event, ) end |
Instance Method Details
#counted! ⇒ Object
set this activity to counted and clear the recorded events
49 50 51 52 53 |
# File 'lib/sir_tracks_alot/activity.rb', line 49 def counted! update(:counted => '1') events.clear true end |
#counted? ⇒ Boolean
is this activity counted?
56 57 58 |
# File 'lib/sir_tracks_alot/activity.rb', line 56 def counted? counted == '1' end |