Class: Stream::Base

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

Direct Known Subclasses

Activity, Aspect, Comments, FollowedTag, Likes, Mention, Multi, Person, Public, Tag

Constant Summary collapse

TYPES_OF_POST_IN_STREAM =
['StatusMessage', 'Reshare']

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(user, opts = {}) ⇒ Base

Returns a new instance of Base.


8
9
10
11
12
13
# File 'lib/stream/base.rb', line 8

def initialize(user, opts={})
  self.user = user
  self.max_time = opts[:max_time]
  self.order = opts[:order]
  self.publisher = Publisher.new(self.user, publisher_opts)
end

Instance Attribute Details

#max_timeObject

Returns the value of attribute max_time


6
7
8
# File 'lib/stream/base.rb', line 6

def max_time
  @max_time
end

#orderObject

Returns the value of attribute order


6
7
8
# File 'lib/stream/base.rb', line 6

def order
  @order
end

#publisherObject

Returns the value of attribute publisher


6
7
8
# File 'lib/stream/base.rb', line 6

def publisher
  @publisher
end

#userObject

Returns the value of attribute user


6
7
8
# File 'lib/stream/base.rb', line 6

def user
  @user
end

Instance Method Details

#aspectAspect

Returns The first aspect in #aspects.

Returns:

  • (Aspect)

    The first aspect in #aspects


66
67
68
# File 'lib/stream/base.rb', line 66

def aspect
  aspects.first
end

#aspectsObject

NOTE: MBS bad bad methods the fact we need these means our views are foobared. please kill them and make them private methods on the streams that need them


61
62
63
# File 'lib/stream/base.rb', line 61

def aspects
  user.post_default_aspects
end

#can_comment?(post) ⇒ Boolean

Returns:

  • (Boolean)

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

def can_comment?(post)
  return true if post.author.local?
  post_is_from_contact?(post)
end

#for_all_aspects?Boolean

Returns:

  • (Boolean)

55
56
57
# File 'lib/stream/base.rb', line 55

def for_all_aspects?
  true
end

requied to implement said stream


16
17
18
# File 'lib/stream/base.rb', line 16

def link(opts={})
  'change me in lib/base_stream.rb!'
end

#peopleActiveRecord::Association<Person>

Returns AR association of people within stream's given aspects.

Returns:

  • (ActiveRecord::Association<Person>)

    AR association of people within stream's given aspects


48
49
50
51
52
# File 'lib/stream/base.rb', line 48

def people
  people_ids = self.stream_posts.map{|x| x.author_id}
  Person.where(:id => people_ids).
    includes(:profile)
end

#post_from_group(post) ⇒ Object


26
27
28
# File 'lib/stream/base.rb', line 26

def post_from_group(post)
  []
end

#postsActiveRecord::Relation<Post>

Returns:

  • (ActiveRecord::Relation<Post>)

36
37
38
# File 'lib/stream/base.rb', line 36

def posts
  Post.all
end

#stream_postsArray<Post>

Returns:


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

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

#titleString

Returns:


31
32
33
# File 'lib/stream/base.rb', line 31

def title
  'a title'
end