Class: SakaiInfo::WikiPageHistory

Inherits:
WikiPage show all
Defined in:
lib/sakai-info/wiki.rb

Instance Attribute Summary

Attributes inherited from WikiPage

#dbrow

Attributes inherited from SakaiObject

#id

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from WikiPage

#content_serialization, #group_admin?, #group_readable?, #group_writable?, #history, #history_summary_serialization, #initialize, #last_updated, #last_updated_by, #owner, #owner_admin?, #owner_readable?, #owner_writable?, #page_name, #permission_string, #permissions_serialization, #public_readable?, #public_writable?, #realm, #realm_name, #revision, #site, #site_id, #summary_serialization

Methods inherited from SakaiObject

#dbrow_only_serialization, #dbrow_serialization, descendants, #object_type_serialization, #serialize, #shell_serialization, #summary_serialization, #to_csv, #to_json, #to_yaml

Constructor Details

This class inherits a constructor from SakaiInfo::WikiPage

Class Method Details

.all_serializationsObject



280
281
282
283
284
285
286
# File 'lib/sakai-info/wiki.rb', line 280

def self.all_serializations
  [
   :default,
   :permissions,
   :content,
  ]
end

.clear_cacheObject



227
228
229
# File 'lib/sakai-info/wiki.rb', line 227

def self.clear_cache
  @@cache = {}
end

.find(id) ⇒ Object



232
233
234
235
236
237
238
239
240
241
# File 'lib/sakai-info/wiki.rb', line 232

def self.find(id)
  if @@cache[id].nil?
    row = DB.connect[:rwikihistory].filter(:id => id).first
    if row.nil?
      raise ObjectNotFoundException.new(WikiPageHistory, id)
    end
    @@cache[id] = WikiPageHistory.new(row)
  end
  @@cache[id]
end

.find_by_wiki_page_id(id) ⇒ Object



255
256
257
258
259
260
261
262
263
# File 'lib/sakai-info/wiki.rb', line 255

def self.find_by_wiki_page_id(id)
  results = []
  DB.connect[:rwikihistory].filter(:rwikiobjectid => id).
    order(:revision).all.collect do |row|
    @@cache[row[:id]] = WikiPageHistory.new(row)
    results << @@cache[row[:id]]
  end
  results
end

Instance Method Details

#contentObject



243
244
245
# File 'lib/sakai-info/wiki.rb', line 243

def content
  @content ||= DB.connect[:rwikihistorycontent].where(:rwikiid => self.id).first[:content].read
end

#default_serializationObject



265
266
267
268
269
# File 'lib/sakai-info/wiki.rb', line 265

def default_serialization
  result = super
  result["current_version"] = self.wiki_page.serialize(:history_summary)
  result
end

#history_serializationObject



271
272
273
274
275
276
277
278
# File 'lib/sakai-info/wiki.rb', line 271

def history_serialization
  {
    "id" => self.id,
    "revision" => self.revision,
    "last_updated" => self.last_updated,
    "last_updated_by" => self.last_updated_by.eid,
  }
end

#wiki_pageObject



251
252
253
# File 'lib/sakai-info/wiki.rb', line 251

def wiki_page
  @wiki_page ||= WikiPage.find(self.wiki_page_id)
end

#wiki_page_idObject



247
248
249
# File 'lib/sakai-info/wiki.rb', line 247

def wiki_page_id
  @dbrow[:rwikiobjectid]
end