Class: ActivityObject

Inherits:
ActiveRecord::Base
  • Object
show all
Includes:
SocialStream::Models::Supertype
Defined in:
app/models/activity_object.rb

Overview

The ActivityObject is any object that receives actions. Examples are creating post, liking a comment, contacting a user.

ActivityObject subtypes

All post, comment and user are objects. Social Stream privides 3 ActivityObject subtypes, Post, Comment and Actor. The application developer can define as many ActivityObject subtypes as required. Objects are added to config/initializers/social_stream.rb

Instance Method Summary collapse

Instance Method Details

#acts_as_actor?Boolean

Does this ActivityObject has Actor?

Returns:

  • (Boolean)


61
62
63
# File 'app/models/activity_object.rb', line 61

def acts_as_actor?
  object_type == "Actor"
end

#author_subjectObject

The subject author



41
42
43
# File 'app/models/activity_object.rb', line 41

def author_subject
  author.subject
end

#objectObject

The object of this activity object



34
35
36
37
38
# File 'app/models/activity_object.rb', line 34

def object
  subtype_instance.is_a?(Actor) ?
    subtype_instance.subject :
    subtype_instance
end

#owner_subjectObject

The subject owner



46
47
48
# File 'app/models/activity_object.rb', line 46

def owner_subject
  owner.subject
end

#post_activityObject

The activity in which this activity_object was created



56
57
58
# File 'app/models/activity_object.rb', line 56

def post_activity
  activities.includes(:activity_verb).where('activity_verbs.name' => 'post').first
end

#user_author_subjectObject

The subject user actor



51
52
53
# File 'app/models/activity_object.rb', line 51

def user_author_subject
  user_author.subject
end