Class: WikiContent::Version
- Inherits:
-
Object
- Object
- WikiContent::Version
- Defined in:
- app/models/wiki_content.rb
Instance Method Summary collapse
-
#previous ⇒ Object
Returns the previous version or nil.
- #project ⇒ Object
- #text ⇒ Object
- #text=(plain) ⇒ Object
Instance Method Details
#previous ⇒ Object
Returns the previous version or nil
103 104 105 106 107 108 |
# File 'app/models/wiki_content.rb', line 103 def previous @previous ||= WikiContent::Version.find(:first, :order => 'version DESC', :include => :author, :conditions => ["wiki_content_id = ? AND version < ?", wiki_content_id, version]) end |
#project ⇒ Object
98 99 100 |
# File 'app/models/wiki_content.rb', line 98 def project page.project end |
#text ⇒ Object
88 89 90 91 92 93 94 95 96 |
# File 'app/models/wiki_content.rb', line 88 def text @text ||= case compression when 'gzip' Zlib::Inflate.inflate(data) else # uncompressed data data end end |
#text=(plain) ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 |
# File 'app/models/wiki_content.rb', line 71 def text=(plain) case Setting.wiki_compression when 'gzip' begin self.data = Zlib::Deflate.deflate(plain, Zlib::BEST_COMPRESSION) self.compression = 'gzip' rescue self.data = plain self.compression = '' end else self.data = plain self.compression = '' end plain end |