Class: SakaiInfo::ForumPost
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from ModProps
included
count_by_date_and_message_type, types, valid_message_type?
Methods inherited from SakaiObject
all_serializations, #dbrow_only_serialization, #dbrow_serialization, descendants, #object_type_serialization, #serialize, #shell_serialization, #to_csv, #to_json, #to_yaml
Constructor Details
#initialize(dbrow) ⇒ ForumPost
Returns a new instance of ForumPost.
231
232
233
234
235
236
237
238
|
# 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
|
Instance Attribute Details
#dbrow ⇒ Object
Returns the value of attribute dbrow.
207
208
209
|
# File 'lib/sakai-info/forum.rb', line 207
def dbrow
@dbrow
end
|
#id ⇒ Object
Returns the value of attribute id.
207
208
209
|
# File 'lib/sakai-info/forum.rb', line 207
def id
@id
end
|
#title ⇒ Object
Returns the value of attribute title.
207
208
209
|
# File 'lib/sakai-info/forum.rb', line 207
def title
@title
end
|
Class Method Details
.clear_cache ⇒ Object
215
216
217
|
# File 'lib/sakai-info/forum.rb', line 215
def self.clear_cache
@@cache = {}
end
|
.count_by_date(d) ⇒ Object
264
265
266
|
# 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) ⇒ Object
256
257
258
|
# 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) ⇒ Object
220
221
222
223
224
225
226
227
228
229
|
# 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) ⇒ Object
.query_by_thread_id(thread_id) ⇒ Object
252
253
254
|
# 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
|
Instance Method Details
#author ⇒ Object
240
241
242
|
# File 'lib/sakai-info/forum.rb', line 240
def author
@author ||= User.find(@dbrow[:created_by])
end
|
#body ⇒ Object
248
249
250
|
# File 'lib/sakai-info/forum.rb', line 248
def body
@dbrow[:body]
end
|
#default_serialization ⇒ Object
268
269
270
271
272
273
274
275
276
|
# 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 ⇒ Object
278
279
280
281
282
283
|
# File 'lib/sakai-info/forum.rb', line 278
def summary_serialization
{
"id" => self.id,
"title" => self.title,
}
end
|
#thread ⇒ Object
244
245
246
|
# File 'lib/sakai-info/forum.rb', line 244
def thread
@thread ||= ForumThread.find(@dbrow[:surrogatekey])
end
|