Class: WikiContent

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

Instance Method Summary collapse

Constructor Details

#initialize(*args) ⇒ WikiContent

Returns a new instance of WikiContent.


36
37
38
39
40
41
# File 'app/models/wiki_content.rb', line 36

def initialize(*args)
  super
  if new_record?
    self.version = 1
  end
end

Instance Method Details

#attachmentsObject


51
52
53
# File 'app/models/wiki_content.rb', line 51

def attachments
  page.nil? ? [] : page.attachments
end

#current_version?Boolean

Return true if the content is the current page content

Returns:

  • (Boolean)

65
66
67
# File 'app/models/wiki_content.rb', line 65

def current_version?
  true
end

#notified_usersObject


55
56
57
# File 'app/models/wiki_content.rb', line 55

def notified_users
  project.notified_users.reject {|user| !visible?(user)}
end

#projectObject


47
48
49
# File 'app/models/wiki_content.rb', line 47

def project
  page.project
end

#recipientsObject

Returns the mail addresses of users that should be notified


60
61
62
# File 'app/models/wiki_content.rb', line 60

def recipients
  notified_users.collect(&:mail)
end

#revert_to!(version) ⇒ Object

Reverts the record to a previous version


70
71
72
73
74
75
76
77
78
79
80
# File 'app/models/wiki_content.rb', line 70

def revert_to!(version)
  if version.wiki_content_id == id
    update_columns(
        :author_id => version.author_id,
        :text => version.text,
        :comments => version.comments,
        :version => version.version,
        :updated_on => version.updated_on
      ) && reload
  end
end

#visible?(user = User.current) ⇒ Boolean

Returns:

  • (Boolean)

43
44
45
# File 'app/models/wiki_content.rb', line 43

def visible?(user=User.current)
  page.visible?(user)
end