class SakaiInfo::ForumPost
Attributes
dbrow[R]
id[R]
title[R]
Public Class Methods
clear_cache()
click to toggle source
# File lib/sakai-info/forum.rb, line 215 def self.clear_cache @@cache = {} end
count_by_date(d)
click to toggle source
# File lib/sakai-info/forum.rb, line 264 def self.count_by_date(d) count_by_date_and_message_type(d, "ME") end
count_by_thread_id(thread_id)
click to toggle source
# File lib/sakai-info/forum.rb, line 256 def self.count_by_thread_id(thread_id) ForumPost.query_by_thread_id(thread_id).count end
find(id)
click to toggle source
# File lib/sakai-info/forum.rb, line 220 def self.find(id) if @@cache[id.to_s].nil? row = DB.connect[:mfr_message_t].where(:id => id, :message_dtype => "ME").first if row.nil? raise ObjectNotFoundException.new(ForumPost, id) end @@cache[id.to_s] = ForumPost.new(row) end @@cache[id.to_s] end
find_by_thread_id(thread_id)
click to toggle source
# File lib/sakai-info/forum.rb, line 260 def self.find_by_thread_id(thread_id) ForumPost.query_by_thread_id(thread_id).all.collect { |r| ForumPost.new(r) } end
new(dbrow)
click to toggle source
# File lib/sakai-info/forum.rb, line 231 def initialize(dbrow) @dbrow = dbrow @dbrow[:body] = dbrow[:body].read @id = dbrow[:id].to_i @title = dbrow[:title] end
query_by_thread_id(thread_id)
click to toggle source
# File lib/sakai-info/forum.rb, line 252 def self.query_by_thread_id(thread_id) DB.connect[:mfr_message_t].where(:surrogatekey => thread_id) end
Public Instance Methods
body()
click to toggle source
# File lib/sakai-info/forum.rb, line 248 def body @dbrow[:body] end
default_serialization()
click to toggle source
# File lib/sakai-info/forum.rb, line 268 def default_serialization { "id" => self.id, "title" => self.title, "author" => self.author.serialize(:summary), "thread" => self.thread.serialize(:summary), "body" => self.body, } end
summary_serialization()
click to toggle source
# File lib/sakai-info/forum.rb, line 278 def summary_serialization { "id" => self.id, "title" => self.title, } end
thread()
click to toggle source
# File lib/sakai-info/forum.rb, line 244 def thread @thread ||= ForumThread.find(@dbrow[:surrogatekey]) end