Class: Activities::CommentObserver

Inherits:
Logger
  • Object
show all
Defined in:
app/observers/activities/comment_observer.rb

Instance Method Summary collapse

Methods inherited from Logger

#after_destroy, #after_save, #before_save, logs_activity

Instance Method Details

#collect_activity_attributes(record) ⇒ Object



13
14
15
16
17
18
# File 'app/observers/activities/comment_observer.rb', line 13

def collect_activity_attributes(record)
  attrs = record.send(:clone_attributes)
  attrs = attrs.slice 'commentable_id', 'body', 'author_name', 'author_email', 'author_url'
  type = record.commentable.has_attribute?('type') ? record.commentable['type'] : record.commentable_type
  attrs.update('commentable_type' => type, 'commentable_title' => record.commentable.title)
end

#initialize_activity(record) ⇒ Object



20
21
22
23
24
25
26
# File 'app/observers/activities/comment_observer.rb', line 20

def initialize_activity(record)
  super.tap do |activity|
    activity.site = record.commentable.site
    activity.section = record.commentable.section
    activity.author = record.author
  end
end