Class: SakaiInfo::ForumThread
Instance Attribute Summary collapse
Attributes inherited from SakaiObject
#id
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from ModProps
included
types, valid_message_type?
Methods inherited from SakaiObject
#dbrow_only_serialization, #dbrow_serialization, descendants, #object_type_serialization, #serialize, #shell_serialization, #to_csv, #to_json, #to_yaml
Constructor Details
Returns a new instance of ForumThread.
149
150
151
152
153
154
|
# File 'lib/sakai-info/forum.rb', line 149
def initialize(dbrow)
@dbrow = dbrow
@id = dbrow[:id].to_i
@title = dbrow[:title]
end
|
Instance Attribute Details
#dbrow ⇒ Object
Returns the value of attribute dbrow.
125
126
127
|
# File 'lib/sakai-info/forum.rb', line 125
def dbrow
@dbrow
end
|
#title ⇒ Object
Returns the value of attribute title.
125
126
127
|
# File 'lib/sakai-info/forum.rb', line 125
def title
@title
end
|
Class Method Details
.all_serializations ⇒ Object
201
202
203
|
# File 'lib/sakai-info/forum.rb', line 201
def self.all_serializations
[ :default, :posts ]
end
|
.clear_cache ⇒ Object
133
134
135
|
# File 'lib/sakai-info/forum.rb', line 133
def self.clear_cache
@@cache = {}
end
|
.count_by_forum_id(forum_id) ⇒ Object
168
169
170
|
# File 'lib/sakai-info/forum.rb', line 168
def self.count_by_forum_id(forum_id)
ForumThread.query_by_forum_id(forum_id).count
end
|
.find(id) ⇒ Object
138
139
140
141
142
143
144
145
146
147
|
# File 'lib/sakai-info/forum.rb', line 138
def self.find(id)
if @@cache[id.to_s].nil?
row = DB.connect[:mfr_topic_t].where(:id => id, :topic_dtype => "DT").first
if row.nil?
raise ObjectNotFoundException.new(ForumThread, id)
end
@@cache[id.to_s] = ForumThread.new(row)
end
@@cache[id.to_s]
end
|
.find_by_forum_id(forum_id) ⇒ Object
.query_by_forum_id(forum_id) ⇒ Object
164
165
166
|
# File 'lib/sakai-info/forum.rb', line 164
def self.query_by_forum_id(forum_id)
DB.connect[:mfr_topic_t].where(:of_surrogatekey => forum_id)
end
|
Instance Method Details
#default_serialization ⇒ Object
176
177
178
179
180
181
182
|
# File 'lib/sakai-info/forum.rb', line 176
def default_serialization
{
"id" => self.id,
"title" => self.title,
"post_count" => self.post_count,
}
end
|
#posts_serialization ⇒ Object
184
185
186
187
188
189
190
191
192
|
# File 'lib/sakai-info/forum.rb', line 184
def posts_serialization
if self.post_count > 0
{
"posts" => self.posts.collect { |p| p.serialize(:summary) }
}
else
{ }
end
end
|
#summary_serialization ⇒ Object
194
195
196
197
198
199
|
# File 'lib/sakai-info/forum.rb', line 194
def summary_serialization
{
"id" => self.id,
"title" => self.title,
}
end
|