Skip to content

Commit

Permalink
Docmented need for include_person option in ActivityLogger
Browse files Browse the repository at this point in the history
  • Loading branch information
mhartl committed May 2, 2008
1 parent 1f7f3ac commit ba33100
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 6 deletions.
14 changes: 8 additions & 6 deletions app/models/comment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
class Comment < ActiveRecord::Base
include ActivityLogger

attr_accessor :commented_person

belongs_to :commentable, :polymorphic => true
belongs_to :commenter, :class_name => "Person",
:foreign_key => "commenter_id"
Expand Down Expand Up @@ -45,12 +47,12 @@ def blog_post_comment?
# For example, for blog post comments it's the blog's person
# For wall comments, it's the person himself.
def commented_person
case commentable.class.to_s
when "Person"
commentable
when "BlogPost"
commentable.blog.person
end
@commented_person ||= case commentable.class.to_s
when "Person"
commentable
when "BlogPost"
commentable.blog.person
end
end

def log_activity
Expand Down
11 changes: 11 additions & 0 deletions lib/activity_logger.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
module ActivityLogger

# Add an activity to the feeds of a person's contacts.
# Usually, we only add to the feeds of the contacts, not the person himself.
# For example, if a person makes a forum post, the activity shows up in
# his contacts' feeds but not his.
# The :include_person option is to handle the case when add_activities
# should include the person as well. This happens when
# someone comments on a person's blog post or wall. In that case, when
# adding activities to the contacts of the wall's or post's owner,
# we should include the owner as well, so that he see's in his feed
# that a comment has been made.
def add_activities(options = {})
person = options[:person]
include_person = options[:include_person]
Expand Down

0 comments on commit ba33100

Please sign in to comment.