Class: WikiContent
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- WikiContent
- Defined in:
- app/models/wiki_content.rb
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.
39 40 41 42 43 44 |
# File 'app/models/wiki_content.rb', line 39 def initialize(*args) super if new_record? self.version = 1 end end |
Instance Method Details
#attachments ⇒ Object
54 55 56 |
# File 'app/models/wiki_content.rb', line 54 def page.nil? ? [] : page. end |
#current_version? ⇒ Boolean
Return true if the content is the current page content
68 69 70 |
# File 'app/models/wiki_content.rb', line 68 def current_version? true end |
#notified_users ⇒ Object
58 59 60 |
# File 'app/models/wiki_content.rb', line 58 def notified_users project.notified_users.reject {|user| !visible?(user)} end |
#project ⇒ Object
50 51 52 |
# File 'app/models/wiki_content.rb', line 50 def project page.project end |
#recipients ⇒ Object
Returns the mail addresses of users that should be notified
63 64 65 |
# File 'app/models/wiki_content.rb', line 63 def recipients notified_users.collect(&:mail) end |
#revert_to!(version) ⇒ Object
Reverts the record to a previous version
73 74 75 76 77 78 79 80 81 82 83 |
# File 'app/models/wiki_content.rb', line 73 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
46 47 48 |
# File 'app/models/wiki_content.rb', line 46 def visible?(user=User.current) page.visible?(user) end |