Class Document
In: app/models/document.rb
Parent: ActiveRecord::Base

Document is a base class for all content in MuraveyWeb.

Methods

Included Modules

WhoInherited

Attributes

cached  [rw]  Rendered version of content
changed  [rw]  Date of the last change
content_type  [rw]  MIME type of data
data  [rw]  Binary or text content
meta  [rw]  Meta instance
parts  [rw]  Folder that belongs to this Document, as a related media store
published  [rw]  Was document allowed to be shown on the site?
revision_comment  [RW] 
size  [rw]  Content size in bytes
symid  [rw]  Document symid
title  [rw]  Human-readable title

Public Class methods

Finds document with a given symid

  @document = Document.find_by_symid("z6k7k1wyl10v2x7g7")

[Source]

    # File app/models/document.rb, line 81
81:   def self.find_by_symid(symid)
82:     Document.find_first([ 'symid=?', symid ])
83:   end

Public Instance methods

[Source]

     # File app/models/document.rb, line 158
158:   def inspect
159:     "<Document: #{id}; parent: #{folder ? folder.name : '-'}; created: #{created}>"
160:   end

[Source]

     # File app/models/document.rb, line 133
133:   def is_index?
134:     if Mapping.find_first([ 'document_id=?', id]) then true else false end
135:   end

URL to view this Document

  @document.link # => "/news/view/10"

[Source]

     # File app/models/document.rb, line 101
101:   def link
102:     "#{viewer}#{id}"
103:   end

[Source]

     # File app/models/document.rb, line 137
137:   def protected?
138:     self.protected >= 0
139:   end

[Source]

     # File app/models/document.rb, line 141
141:   def published?
142:     self.published == 1
143:   end

[Source]

     # File app/models/document.rb, line 145
145:   def render_date
146:     time = self.created
147:     time.strftime("%b %d, %H:%M")
148:   end

[Source]

     # File app/models/document.rb, line 150
150:   def render_size 
151:     if self.size < 1024
152:       "#{self.size} bytes"
153:     else
154:       "#{self.size / 1024} kB"
155:     end
156:   end

[Validate]