public
Fork of halorgium/mephisto
Description: A mirror of the mephisto code-base
Homepage: http://mephistoblog.com/
Clone URL: git://github.com/technoweenie/mephisto.git
Search Repo:
Click here to lend your support to: mephisto and make a donation at www.pledgie.com !
mephisto / app / cachers / comment_observer.rb
100644 18 lines (15 sloc) 0.562 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
class CommentObserver < ArticleObserver
  def self.disabled?
    Thread.current[:comment_observer_disabled]
  end
  
  def disabled=(value)
    Thread.current[:comment_observer_disabled] = value
  end
  
  def after_save(record)
    @event.update_attributes :title => record.article.title, :body => record.body, :site => record.article.site,
      :article => record.article, :author => record.author, :comment => record if record.approved? && !self.class.disabled?
  end
 
  def after_destroy(record)
    Event.destroy_all ['comment_id = ?', record.id]
  end
end