You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
676 B

  1. class StreamEntry < ActiveRecord::Base
  2. belongs_to :account, inverse_of: :stream_entries
  3. belongs_to :activity, polymorphic: true
  4. validates :account, :activity, presence: true
  5. def object_type
  6. targeted? ? :activity : self.activity.object_type
  7. end
  8. def verb
  9. self.activity.verb
  10. end
  11. def targeted?
  12. [:follow, :share, :favorite].include? verb
  13. end
  14. def target
  15. self.activity.target
  16. end
  17. def title
  18. self.activity.title
  19. end
  20. def content
  21. self.activity.content
  22. end
  23. def threaded?
  24. verb == :favorite || object_type == :comment
  25. end
  26. def thread
  27. self.activity.thread
  28. end
  29. def mentions
  30. self.activity.mentions
  31. end
  32. end