Class: Stream::Tag

Inherits:
Base
  • Object
show all
Defined in:
lib/stream/tag.rb

Overview

Copyright © 2010-2011, Diaspora Inc. This file is

licensed under the Affero General Public License version 3 or later.  See
the COPYRIGHT file.

Constant Summary

Constants inherited from Base

Base::TYPES_OF_POST_IN_STREAM

Instance Attribute Summary collapse

Attributes inherited from Base

#max_time, #order, #publisher, #user

Instance Method Summary collapse

Methods inherited from Base

#aspect, #aspects, #can_comment?, #for_all_aspects?, #link, #people, #post_from_group, #title

Constructor Details

#initialize(user, tag_name, opts = {}) ⇒ Tag

Returns a new instance of Tag.


10
11
12
13
14
15
# File 'lib/stream/tag.rb', line 10

def initialize(user, tag_name, opts={})
  self.tag_name = tag_name
  self.people_page = opts[:page] || 1
  self.people_per_page = 15
  super(user, opts)
end

Instance Attribute Details

#people_pageObject

Returns the value of attribute people_page


8
9
10
# File 'lib/stream/tag.rb', line 8

def people_page
  @people_page
end

#people_per_pageObject

Returns the value of attribute people_per_page


8
9
10
# File 'lib/stream/tag.rb', line 8

def people_per_page
  @people_per_page
end

#tag_nameObject

Returns the value of attribute tag_name


8
9
10
# File 'lib/stream/tag.rb', line 8

def tag_name
  @tag_name
end

Instance Method Details

#display_tag_nameObject


21
22
23
# File 'lib/stream/tag.rb', line 21

def display_tag_name
  @display_tag_name ||= "##{tag_name}"
end

#postsObject


33
34
35
36
37
38
39
# File 'lib/stream/tag.rb', line 33

def posts
  @posts ||= if user
               StatusMessage.user_tag_stream(user, tag.id)
             else
               StatusMessage.public_tag_stream(tag.id)
             end
end

#stream_postsObject


41
42
43
44
# File 'lib/stream/tag.rb', line 41

def stream_posts
  return [] unless tag
  super
end

#tagObject


17
18
19
# File 'lib/stream/tag.rb', line 17

def tag
  @tag ||= ActsAsTaggableOn::Tag.named(tag_name).first
end

#tagged_peopleObject


25
26
27
# File 'lib/stream/tag.rb', line 25

def tagged_people
  @people ||= ::Person.profile_tagged_with(tag_name).paginate(:page => people_page, :per_page => people_per_page)
end

#tagged_people_countObject


29
30
31
# File 'lib/stream/tag.rb', line 29

def tagged_people_count
  @people_count ||= ::Person.profile_tagged_with(tag_name).count
end