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.


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

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


4
5
6
# File 'lib/stream/base.rb', line 4

def max_time
  @max_time
end

#orderObject

Returns the value of attribute order


4
5
6
# File 'lib/stream/base.rb', line 4

def order
  @order
end

#publisherObject

Returns the value of attribute publisher


4
5
6
# File 'lib/stream/base.rb', line 4

def publisher
  @publisher
end

#userObject

Returns the value of attribute user


4
5
6
# File 'lib/stream/base.rb', line 4

def user
  @user
end

Instance Method Details

#aspectAspect

Returns The first aspect in #aspects.

Returns:

  • (Aspect)

    The first aspect in #aspects


74
75
76
# File 'lib/stream/base.rb', line 74

def aspect
  aspects.first
end

#aspect_idsObject


78
79
80
# File 'lib/stream/base.rb', line 78

def aspect_ids
  aspects.map{|x| x.id}
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


69
70
71
# File 'lib/stream/base.rb', line 69

def aspects
  user.aspects
end

#can_comment?(post) ⇒ Boolean

Returns:

  • (Boolean)

19
20
21
22
# File 'lib/stream/base.rb', line 19

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

Returns:


58
59
60
# File 'lib/stream/base.rb', line 58

def contacts_link
  Rails.application.routes.url_helpers.contacts_path
end

#contacts_titleString

Returns def contacts_title 'change me in lib/base_stream.rb!'.

Returns:

  • (String)

    def contacts_title 'change me in lib/base_stream.rb!'


53
54
55
# File 'lib/stream/base.rb', line 53

def contacts_title
  'change me in lib/base_stream.rb!'
end

#for_all_aspects?Boolean

Returns:

  • (Boolean)

63
64
65
# File 'lib/stream/base.rb', line 63

def for_all_aspects?
  true
end

requied to implement said stream


14
15
16
# File 'lib/stream/base.rb', line 14

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


46
47
48
49
50
# File 'lib/stream/base.rb', line 46

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


24
25
26
# File 'lib/stream/base.rb', line 24

def post_from_group(post)
  []
end

#postsActiveRecord::Relation<Post>

Returns:

  • (ActiveRecord::Relation<Post>)

34
35
36
# File 'lib/stream/base.rb', line 34

def posts
  Post.scoped
end

#stream_postsArray<Post>

Returns:


39
40
41
42
43
# File 'lib/stream/base.rb', line 39

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:


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

def title
  'a title'
end