Class: ActivityObject
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- ActivityObject
- Includes:
- Properties
- Defined in:
- app/models/activity_object.rb,
app/models/activity_object/properties.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
Defined Under Namespace
Modules: Properties
Instance Attribute Summary collapse
-
#_activity_parent_id ⇒ Object
Returns the value of attribute _activity_parent_id.
Instance Method Summary collapse
- #_activity_parent ⇒ Object
-
#action_from(actor) ⇒ Object
Return the Action model to an Actor.
- #actor! ⇒ Object
-
#acts_as_actor? ⇒ Boolean
Does this ActivityObject has Actor?.
-
#authored_or_owned_by?(subject) ⇒ Boolean
subject was the author, user author or owner of this ActivityObject?.
-
#build_post_activity ⇒ Object
Build the post activity when this object is not saved.
-
#object ⇒ Object
The object of this activity object.
-
#post_activity ⇒ Object
The activity in which this activity_object was created.
-
#received_action_by(actor_id) ⇒ Object
Obtain the ActivityAction between this ActivityObject and the Actor identified by actor_id.
-
#received_action_by!(actor_id) ⇒ Object
Obtain received_action_by(actor_id) or create it if it does not exist.
-
#received_role_action(role) ⇒ Object
Get the first ActivityAction that has activated the role flag.
-
#represented_author? ⇒ Boolean
Was the author represented when this ActivityObject was created?.
Methods included from Properties
Methods included from Properties::HolderMethods
Instance Attribute Details
#_activity_parent_id ⇒ Object
Returns the value of attribute _activity_parent_id.
12 13 14 |
# File 'app/models/activity_object.rb', line 12 def _activity_parent_id @_activity_parent_id end |
Instance Method Details
#_activity_parent ⇒ Object
234 235 236 |
# File 'app/models/activity_object.rb', line 234 def _activity_parent @_activity_parent ||= Activity.find(_activity_parent_id) end |
#action_from(actor) ⇒ Object
Return the Action model to an Actor
217 218 219 |
# File 'app/models/activity_object.rb', line 217 def action_from(actor) received_actions.sent_by(actor).first end |
#actor! ⇒ Object
212 213 214 |
# File 'app/models/activity_object.rb', line 212 def actor! actor || raise("Unknown Actor for ActivityObject: #{ inspect }") end |
#acts_as_actor? ⇒ Boolean
Does this ActivityObject has Actor?
208 209 210 |
# File 'app/models/activity_object.rb', line 208 def acts_as_actor? object_type == "Actor" end |
#authored_or_owned_by?(subject) ⇒ Boolean
subject was the author, user author or owner of this ActivityObject?
187 188 189 190 191 192 193 |
# File 'app/models/activity_object.rb', line 187 def (subject) return false if subject.blank? received_actions. merge(ActivityAction.(subject)). any? end |
#build_post_activity ⇒ Object
Build the post activity when this object is not saved
227 228 229 230 231 232 |
# File 'app/models/activity_object.rb', line 227 def build_post_activity Activity.new :author => , :user_author => , :owner => owner, :relation_ids => relation_ids end |
#object ⇒ Object
The object of this activity object
201 202 203 204 205 |
# File 'app/models/activity_object.rb', line 201 def object subtype_instance.is_a?(Actor) ? subtype_instance.subject : subtype_instance end |
#post_activity ⇒ Object
The activity in which this activity_object was created
222 223 224 |
# File 'app/models/activity_object.rb', line 222 def post_activity activities.includes(:activity_verb).where('activity_verbs.name' => 'post').first end |
#received_action_by(actor_id) ⇒ Object
Obtain the ActivityAction between this ActivityObject and the Actor identified by actor_id
132 133 134 135 |
# File 'app/models/activity_object.rb', line 132 def received_action_by(actor_id) received_actions. find{ |a| a.actor_id == actor_id } end |
#received_action_by!(actor_id) ⇒ Object
Obtain received_action_by(actor_id) or create it if it does not exist
139 140 141 142 |
# File 'app/models/activity_object.rb', line 139 def received_action_by!(actor_id) received_action_by(actor_id) || received_actions.build(:actor_id => actor_id) end |
#received_role_action(role) ⇒ Object
Get the first ActivityAction that has activated the role flag
145 146 147 148 |
# File 'app/models/activity_object.rb', line 145 def received_role_action(role) received_actions. find{ |a| a.__send__ "#{ role }?" } end |
#represented_author? ⇒ Boolean
Was the author represented when this ActivityObject was created?
196 197 198 |
# File 'app/models/activity_object.rb', line 196 def != end |