Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Ricard Forniol
committed
May 27, 2011
1 parent
3ddeea4
commit a77b7c2
Showing
9 changed files
with
158 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
module ActivityCounter | ||
module Model | ||
module Cached | ||
module ClassMethods | ||
|
||
## Add status_update methods and trigger them to their events | ||
def configure_cached_class | ||
self.instance_eval <<-HELLO | ||
def update_status_counter_on_create | ||
status.current.counter.increase | ||
end | ||
def update_status_counter_on_change | ||
if status.changed? | ||
status.old.counter.decrease | ||
status.new.counter.increase | ||
end | ||
end | ||
def update_status_counter_on_destroy | ||
status.current.counter.decrease | ||
end | ||
HELLO | ||
|
||
after_create :update_status_counter_on_create | ||
after_update :update_status_counter_on_change | ||
before_destroy :update_status_counter_on_destroy | ||
|
||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module ActivityCounter | ||
module Model | ||
module Source | ||
module ClassMethods | ||
|
||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
class Counter < ActiveRecord::Base | ||
acts_as_activity_counter | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.