Class: Activity
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Activity
- Defined in:
- app/models/activity.rb
Overview
Activities follow the Activity Streams standard.
Activities and Ties
Every activity is attached to a Tie, which defines the sender, the receiver and the relation in which the activity is transferred
Wall
The Activity.wall(ties) scope provides all the activities attached to a set of ties
Instance Method Summary collapse
-
#comments ⇒ Object
The comments about this activity.
-
#direct_object ⇒ Object
The first object of this activity.
-
#liked_by(user) ⇒ Object
:nodoc:.
-
#liked_by?(user) ⇒ Boolean
Does user like this activity?.
-
#likes ⇒ Object
The ‘like’ qualifications emmited to this activities.
-
#verb ⇒ Object
The name of the verb of this activity.
-
#verb=(name) ⇒ Object
Set the name of the verb of this activity.
Instance Method Details
#comments ⇒ Object
The comments about this activity
52 53 54 |
# File 'app/models/activity.rb', line 52 def comments children.includes(:activity_objects).where('activity_objects.object_type' => "Comment") end |
#direct_object ⇒ Object
The first object of this activity
71 72 73 |
# File 'app/models/activity.rb', line 71 def direct_object activity_objects.first.try(:object) end |
#liked_by(user) ⇒ Object
:nodoc:
61 62 63 |
# File 'app/models/activity.rb', line 61 def liked_by(user) #:nodoc: likes.includes(:tie) & Tie.sent_by(user) end |
#liked_by?(user) ⇒ Boolean
Does user like this activity?
66 67 68 |
# File 'app/models/activity.rb', line 66 def liked_by?(user) liked_by(user).present? end |
#likes ⇒ Object
The ‘like’ qualifications emmited to this activities
57 58 59 |
# File 'app/models/activity.rb', line 57 def likes children.joins(:activity_verb).where('activity_verbs.name' => "like") end |
#verb ⇒ Object
The name of the verb of this activity
42 43 44 |
# File 'app/models/activity.rb', line 42 def verb activity_verb.name end |
#verb=(name) ⇒ Object
Set the name of the verb of this activity
47 48 49 |
# File 'app/models/activity.rb', line 47 def verb=(name) self.activity_verb = ActivityVerb[name] end |