Class: Activity

Inherits:
ActiveRecord::Base
  • Object
show all
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

Instance Method Details

#commentsObject

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_objectObject

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?

Returns:

  • (Boolean)


66
67
68
# File 'app/models/activity.rb', line 66

def liked_by?(user)
  liked_by(user).present?
end

#likesObject

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

#verbObject

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