Class: Posting

Inherits:
Object
  • Object
show all
Includes:
ContentItem, Mongoid::FullTextSearch
Defined in:
app/models/posting.rb

Overview

A Posting is a blogabble semi-static content-item.

Instance Method Summary (collapse)

Methods included from ContentItem

included, #markdown, #normalized_tags_with_weight

Instance Method Details

- (Object) fulltext



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

def fulltext
  title + " " + body + " " + comments.map(&:comment).join(" ")
end

- (Boolean) has_recipient?(recipient)

Returns:

  • (Boolean)


80
81
82
# File 'app/models/posting.rb', line 80

def has_recipient?(recipient)
  self.recipient_ids.include? recipient.id
end

- (Object) new_tag



69
70
# File 'app/models/posting.rb', line 69

def new_tag
end

- (Object) new_tag=(new_tag)



72
73
74
75
76
77
# File 'app/models/posting.rb', line 72

def new_tag=(new_tag)
  unless new_tag.blank?
    self.tags_array += [new_tag]
    self.tags_array.uniq!
  end
end

- (Boolean) public?

Returns:

  • (Boolean)


84
85
86
# File 'app/models/posting.rb', line 84

def public?
  self.recipient_ids.empty?
end

- (Object) recipient_tokens



88
89
# File 'app/models/posting.rb', line 88

def recipient_tokens
end

- (Object) recipient_tokens=(new_tokens)



91
92
93
94
95
96
97
98
# File 'app/models/posting.rb', line 91

def recipient_tokens=(new_tokens)
  self.recipient_group_ids = new_tokens.split(",").map { |token|
    self.user.user_groups.find(token).id 
  }
  self.recipient_ids = self.recipient_group_ids.map { |group_id|
    group = self.user.user_groups.find(group_id).members
  }.flatten.uniq.compact
end

- (Object) render_body(view_context = nil)

Render the body



59
60
61
62
63
64
65
66
67
# File 'app/models/posting.rb', line 59

def render_body(view_context=nil)
  @view_context ||= view_context
  if @view_context
    @view_context.concat render_for_html(self.body,@view_context).html_safe
    return ""
  else
    render_for_html(self.body).html_safe
  end
end