Sha256: 45e69772441e9bd48e32a5632b61489681a6a4f217e611eecf9847d5ec5e6680
Contents?: true
Size: 1016 Bytes
Versions: 2
Compression:
Stored size: 1016 Bytes
Contents
if defined?(Comment) module Activities class CommentObserver < Activities::Logger observe :comment logs_activity do |log| log.edited :if => [:body_changed?, {:not => :new_record?}] log.approved :if => [:approved_changed?, :approved?] log.unapproved :if => [:approved_changed?, :unapproved?] end 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 def initialize_activity(record) super.tap do |activity| activity.site = record.commentable.site activity.section = record.commentable.section activity.author = record.author end end end end end
Version data entries
2 entries across 2 versions & 2 rubygems
Version | Path |
---|---|
adva_activity-0.0.1 | app/observers/activities/comment_observer.rb |
adva-0.0.1 | adva_activity/app/observers/activities/comment_observer.rb |