class SakaiInfo::PrivateMessage

Attributes

dbrow[R]
id[R]
title[R]

Public Class Methods

clear_cache() click to toggle source
# File lib/sakai-info/private_message.rb, line 22
def self.clear_cache
  @@cache = {}
end
count_by_date(d) click to toggle source
# File lib/sakai-info/private_message.rb, line 58
def self.count_by_date(d)
  count_by_date_and_message_type(d, "PM")
end
find(id) click to toggle source
# File lib/sakai-info/private_message.rb, line 27
def self.find(id)
  if @@cache[id.to_s].nil?
    row = DB.connect[:mfr_message_t].where(:id => id, :message_dtype => "PM").first
    if row.nil?
      raise ObjectNotFoundException.new(PrivateMessage, id)
    end
    @@cache[id.to_s] = PrivateMessage.new(row)
  end
  @@cache[id.to_s]
end
new(dbrow) click to toggle source
# File lib/sakai-info/private_message.rb, line 38
def initialize(dbrow)
  @dbrow = dbrow

  @dbrow[:body] = dbrow[:body].read
  @dbrow[:recipients_as_text] = dbrow[:recipients_as_text].read

  @id = dbrow[:id].to_i
  @title = dbrow[:title]
end

Public Instance Methods

author() click to toggle source
# File lib/sakai-info/private_message.rb, line 48
def author
  # apparently the 'author' field is just a display string?!?
  # as of 2.8, perhaps?
  @author ||= User.find(@dbrow[:created_by])
end
body() click to toggle source
# File lib/sakai-info/private_message.rb, line 54
def body
  @dbrow[:body]
end
default_serialization() click to toggle source
# File lib/sakai-info/private_message.rb, line 62
def default_serialization
  {
    "id" => self.id,
    "title" => self.title,
    "author" => self.author.serialize(:summary),
    "body" => self.body,
  }
end
summary_serialization() click to toggle source
# File lib/sakai-info/private_message.rb, line 71
def summary_serialization
  {
    "id" => self.id,
    "title" => self.title,
  }
end