Class: SakaiInfo::Forum
- Inherits:
-
SakaiObject
- Object
- SakaiObject
- SakaiInfo::Forum
- Defined in:
- lib/sakai-info/message.rb
Constant Summary collapse
- @@cache =
{}
- @@cache_by_site_id =
{}
Instance Attribute Summary collapse
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#title ⇒ Object
readonly
Returns the value of attribute title.
Class Method Summary collapse
Instance Method Summary collapse
- #default_serialization ⇒ Object
-
#initialize(id, title) ⇒ Forum
constructor
A new instance of Forum.
- #summary_serialization ⇒ Object
Methods inherited from SakaiObject
all_serializations, #dbrow_only_serialization, #dbrow_serialization, #object_type_serialization, #serialize, #to_json, #to_yaml
Constructor Details
#initialize(id, title) ⇒ Forum
Returns a new instance of Forum.
66 67 68 69 |
# File 'lib/sakai-info/message.rb', line 66 def initialize(id, title) @id = id.to_i @title = title end |
Instance Attribute Details
#id ⇒ Object (readonly)
Returns the value of attribute id.
64 65 66 |
# File 'lib/sakai-info/message.rb', line 64 def id @id end |
#title ⇒ Object (readonly)
Returns the value of attribute title.
64 65 66 |
# File 'lib/sakai-info/message.rb', line 64 def title @title end |
Class Method Details
.count_by_site_id(site_id) ⇒ Object
73 74 75 76 77 78 |
# File 'lib/sakai-info/message.rb', line 73 def self.count_by_site_id(site_id) DB.connect.fetch("select count(*) as count from mfr_open_forum_t " + "where surrogatekey = (select id from mfr_area_t " + "where type_uuid = ? and context_id = ?)", MessageTypeUUID::FORUM_POST, site_id).first[:count].to_i end |
.find_by_site_id(site_id) ⇒ Object
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 |
# File 'lib/sakai-info/message.rb', line 81 def self.find_by_site_id(site_id) if @@cache_by_site_id[site_id].nil? @@cache_by_site_id[site_id] = [] DB.connect.fetch("select id, title from mfr_open_forum_t " + "where surrogatekey = (select id from mfr_area_t " + "where type_uuid = ? " + "and context_id = ?) order by sort_index", MessageTypeUUID::FORUM_POST, site_id) do |row| id = row[:id].to_i.to_s title = row[:title] @@cache[id] = Forum.new(id, title) @@cache_by_site_id[site_id] << @@cache[id] end end @@cache_by_site_id[site_id] end |
Instance Method Details
#default_serialization ⇒ Object
98 99 100 101 102 103 |
# File 'lib/sakai-info/message.rb', line 98 def default_serialization { "id" => self.id, "title" => self.title } end |
#summary_serialization ⇒ Object
105 106 107 108 109 110 |
# File 'lib/sakai-info/message.rb', line 105 def summary_serialization { "id" => self.id, "title" => self.title } end |