Class: Cornerstone::Discussion
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Cornerstone::Discussion
- Defined in:
- app/models/cornerstone/discussion.rb
Constant Summary collapse
- STATUS =
CONSTANTS == #
Cornerstone::Config.discussion_statuses
Instance Method Summary collapse
-
#author_name ⇒ Object
INSTANCE METHODS == #.
-
#closed? ⇒ Boolean
returns true if discussion is ‘closed’.
-
#created_by?(check_user) ⇒ Boolean
returns true if it was created by given user or if given user is an admin.
-
#participants(exclude_email = nil) ⇒ Object
returns an array of participants for the discussion.
-
#participants_email_list(exclude_email = nil) ⇒ Object
return a nicely formatted string for emailing i.e.
Instance Method Details
#author_name ⇒ Object
INSTANCE METHODS == #
39 40 41 |
# File 'app/models/cornerstone/discussion.rb', line 39 def self.posts.first. end |
#closed? ⇒ Boolean
returns true if discussion is ‘closed’
44 45 46 |
# File 'app/models/cornerstone/discussion.rb', line 44 def closed? self.status == Cornerstone::Discussion::STATUS.last end |
#created_by?(check_user) ⇒ Boolean
returns true if it was created by given user or if given user is an admin
49 50 51 52 53 |
# File 'app/models/cornerstone/discussion.rb', line 49 def created_by?(check_user) return false unless check_user.present? return true if check_user.cornerstone_admin? self.user && self.user == check_user end |
#participants(exclude_email = nil) ⇒ Object
returns an array of participants for the discussion
56 57 58 59 60 61 62 63 64 |
# File 'app/models/cornerstone/discussion.rb', line 56 def participants(exclude_email=nil) ps = [] self.posts.each do |p| if p. && p. ps << [p., p.] end end ps.delete_if{|p| p[1] == exclude_email}.uniq end |
#participants_email_list(exclude_email = nil) ⇒ Object
return a nicely formatted string for emailing i.e. Name <email_address>, Name <email_address>
68 69 70 |
# File 'app/models/cornerstone/discussion.rb', line 68 def participants_email_list(exclude_email=nil) participants(exclude_email).collect{ |p| "#{p[0]} <#{p[1]}>" }.join(", ") end |