about summary refs log tree commit diff
path: root/app/models/stream_entry.rb
blob: a3ae099a1235edebe132eda22da7841c9565aaff (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
class StreamEntry < ActiveRecord::Base
  belongs_to :account, inverse_of: :stream_entries
  belongs_to :activity, polymorphic: true

  validates :account, :activity, presence: true

  def object_type
    targeted? ? :activity : self.activity.object_type
  end

  def verb
    self.activity.verb
  end

  def targeted?
    [:follow, :share, :favorite].include? verb
  end

  def target
    self.activity.target
  end

  def title
    self.activity.title
  end

  def content
    self.activity.content
  end

  def threaded?
    [:favorite, :comment].include? verb
  end

  def thread
    self.activity.thread
  end

  def mentions
    self.activity.mentions
  end
end