Class: Stream::Person

Inherits:
Base
  • Object
show all
Defined in:
lib/stream/person.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, person, opts = {}) ⇒ Person

Returns a new instance of Person.


11
12
13
14
# File 'lib/stream/person.rb', line 11

def initialize(user, person, opts={})
  self.person = person
  super(user, opts)
end

Instance Attribute Details

#personObject

Returns the value of attribute person


9
10
11
# File 'lib/stream/person.rb', line 9

def person
  @person
end

Instance Method Details

#postsActiveRecord::Association<Post>

Returns AR association of posts.

Returns:

  • (ActiveRecord::Association<Post>)

    AR association of posts


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

def posts
  @posts ||= user.present? ? user.posts_from(@person) : @person.posts.where(:public => true)
end

#stream_postsArray<Post>

Returns:


22
23
24
25
26
# File 'lib/stream/person.rb', line 22

def stream_posts
  posts.for_a_stream(max_time, order, user, true).tap do |posts|
    like_posts_for_stream!(posts) # some sql person could probably do this with joins.
  end
end