Class: WikiContent
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- WikiContent
- Defined in:
- app/models/wiki_content.rb
Overview
Instance Method Summary collapse
- #attachments ⇒ Object
-
#current_version? ⇒ Boolean
Return true if the content is the current page content.
-
#initialize(*args) ⇒ WikiContent
constructor
A new instance of WikiContent.
- #notified_users ⇒ Object
- #project ⇒ Object
-
#recipients ⇒ Object
Returns the mail addresses of users that should be notified.
-
#revert_to!(version) ⇒ Object
Reverts the record to a previous version.
- #visible?(user = User.current) ⇒ Boolean
Constructor Details
#initialize(*args) ⇒ WikiContent
Returns a new instance of WikiContent
34 35 36 37 38 39 |
# File 'app/models/wiki_content.rb', line 34 def initialize(*args) super if new_record? self.version = 1 end end |
Instance Method Details
#attachments ⇒ Object
49 50 51 |
# File 'app/models/wiki_content.rb', line 49 def page.nil? ? [] : page. end |
#current_version? ⇒ Boolean
Return true if the content is the current page content
63 64 65 |
# File 'app/models/wiki_content.rb', line 63 def current_version? true end |
#notified_users ⇒ Object
53 54 55 |
# File 'app/models/wiki_content.rb', line 53 def notified_users project.notified_users.reject {|user| !visible?(user)} end |
#project ⇒ Object
45 46 47 |
# File 'app/models/wiki_content.rb', line 45 def project page.project end |
#recipients ⇒ Object
Returns the mail addresses of users that should be notified
58 59 60 |
# File 'app/models/wiki_content.rb', line 58 def recipients notified_users.collect(&:mail) end |
#revert_to!(version) ⇒ Object
Reverts the record to a previous version
68 69 70 71 72 73 74 75 76 77 78 |
# File 'app/models/wiki_content.rb', line 68 def revert_to!(version) if version.wiki_content_id == id update_columns( :author_id => version., :text => version.text, :comments => version.comments, :version => version.version, :updated_on => version.updated_on ) && reload end end |
#visible?(user = User.current) ⇒ Boolean
41 42 43 |
# File 'app/models/wiki_content.rb', line 41 def visible?(user=User.current) page.visible?(user) end |