Class: WikiContent::Version

Inherits:
Object
  • Object
show all
Defined in:
app/models/wiki_content.rb

Instance Method Summary (collapse)

Instance Method Details

- (Object) previous

Returns the previous version or nil



82
83
84
85
86
87
# File 'app/models/wiki_content.rb', line 82

def previous
  @previous ||= WikiContent::Version.find(:first, 
                                          :order => 'version DESC',
                                          :include => :author,
                                          :conditions => ["wiki_content_id = ? AND version < ?", wiki_content_id, version])
end

- (Object) project



77
78
79
# File 'app/models/wiki_content.rb', line 77

def project
  page.project
end

- (Object) text



67
68
69
70
71
72
73
74
75
# File 'app/models/wiki_content.rb', line 67

def text
  @text ||= case compression
  when 'gzip'
     Zlib::Inflate.inflate(data)
  else
    # uncompressed data
    data
  end      
end

- (Object) text=(plain)



50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
# File 'app/models/wiki_content.rb', line 50

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