Permalink
Browse files

Update hook definition to use one statement.

Signed-off-by: David Celis <david@davidcelis.com>
  • Loading branch information...
1 parent c1f0125 commit 89f6c6ae422f278fe8675b07a498943a4277835c @davidcelis committed Aug 4, 2012
Showing with 5 additions and 18 deletions.
  1. +1 −1 Gemfile.lock
  2. +4 −17 lib/recommendable/acts_as_recommended_to.rb
View
2 Gemfile.lock
@@ -2,7 +2,7 @@ PATH
remote: .
specs:
recommendable (1.1.5)
- hooks
+ hooks (>= 0.2.1)
rails (>= 3.0.0)
redis (>= 2.2.0)
View
21 lib/recommendable/acts_as_recommended_to.rb
@@ -29,23 +29,10 @@ def acts_as_recommended_to
before_destroy :remove_from_similarities, :remove_recommendations
- # This is just until apotonick merges my change into his published gem. I promise.
- define_hook :before_like
- define_hook :after_like
- define_hook :before_unlike
- define_hook :after_unlike
- define_hook :before_dislike
- define_hook :after_dislike
- define_hook :before_undislike
- define_hook :after_undislike
- define_hook :before_stash
- define_hook :after_stash
- define_hook :before_unstash
- define_hook :after_unstash
- define_hook :before_ignore
- define_hook :after_ignore
- define_hook :before_unignore
- define_hook :after_unignore
+ define_hooks :before_like, :after_like, :before_unlike, :after_unlike,
+ :before_dislike, :after_dislike, :before_undislike, :after_undislike,
+ :before_stash, :after_stash, :before_unstash, :after_unstash,
+ :before_ignore, :after_ignore, :before_unignore, :after_unignore
%w(like dislike ignore).each do |action|
send "before_#{action}", lambda { |obj| completely_unrecommend obj }

0 comments on commit 89f6c6a

Please sign in to comment.