Sha256: 9ca60f431b2ffc5a5b4f8213ffab1bb7b3ef4a34d480ec912322068aec05075b

Contents?: true

Size: 1.71 KB

Versions: 12

Compression:

Stored size: 1.71 KB

Contents

# 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 {SocialStream::Models::Object 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+
#
class ActivityObject < ActiveRecord::Base
  @subtypes_name = :object
  include SocialStream::Models::Supertype

  acts_as_taggable
  
  # Author can be any type of Actor: User, Group, etc.
  belongs_to :author,
             :class_name => "Actor"
  # Owner is the wall's subject this object is posted to
  belongs_to :owner,
             :class_name => "Actor"

  # UserAuthor is the real user behind the Author
  belongs_to :user_author,
             :class_name => "Actor"

  has_many :activity_object_activities, :dependent => :destroy
  has_many :activities, :through => :activity_object_activities

  validates_presence_of :object_type

  # The object of this activity object
  def object
    subtype_instance.is_a?(Actor) ?
      subtype_instance.subject :
      subtype_instance
  end

  # The {SocialStream::Models::Subject subject} author
  def author_subject
    author.subject
  end

  # The {SocialStream::Models::Subject subject} owner
  def owner_subject
    owner.subject
  end

  # The {SocialStream::Models::Subject subject} user actor
  def user_author_subject
    user_author.subject
  end

  # The activity in which this activity_object was created
  def post_activity
    activities.includes(:activity_verb).where('activity_verbs.name' => 'post').first
  end
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
social_stream-0.14.1 base/app/models/activity_object.rb
social_stream-base-0.10.5 app/models/activity_object.rb
social_stream-0.14.0 base/app/models/activity_object.rb
social_stream-base-0.10.4 app/models/activity_object.rb
social_stream-0.13.3 base/app/models/activity_object.rb
social_stream-base-0.10.3 app/models/activity_object.rb
social_stream-0.13.2 base/app/models/activity_object.rb
social_stream-base-0.10.2 app/models/activity_object.rb
social_stream-0.13.1 base/app/models/activity_object.rb
social_stream-base-0.10.1 app/models/activity_object.rb
social_stream-0.13.0 base/app/models/activity_object.rb
social_stream-base-0.10.0 app/models/activity_object.rb