Module: SocialStream::Models::Object::InstanceMethods
- Defined in:
- lib/social_stream/models/object.rb
Instance Method Summary collapse
- #_activity_parent ⇒ Object
- #_contact ⇒ Object
- #_contact_id ⇒ Object
- #_relation_ids ⇒ Object
-
#activities ⇒ Object
All the activities with this object.
- #activity_object! ⇒ Object
-
#build_post_activity ⇒ Object
Build the post activity when this object is not saved.
-
#create_activity_object_with_type ⇒ Object
Build corresponding ActivityObject including this class type.
-
#method_missing(method, *args, &block) ⇒ Object
Delegate missing methods to ActivityObject, if they exist there.
-
#represented_author? ⇒ Boolean
Was the author represented with this object was created?.
-
#respond_to?(*args) ⇒ Boolean
ActivityObject handles some methods.
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method, *args, &block) ⇒ Object
Delegate missing methods to ActivityObject, if they exist there
36 37 38 39 40 41 42 43 44 |
# File 'lib/social_stream/models/object.rb', line 36 def method_missing(method, *args, &block) super rescue NameError => object_error # These methods must be raised to avoid loops (the :activity_object association calls here again) exceptions = [ :_activity_object_id ] raise object_error if exceptions.include?(method) activity_object!.__send__ method, *args, &block end |
Instance Method Details
#_activity_parent ⇒ Object
104 105 106 |
# File 'lib/social_stream/models/object.rb', line 104 def _activity_parent @_activity_parent ||= Activity.find(_activity_parent_id) end |
#_contact ⇒ Object
78 79 80 |
# File 'lib/social_stream/models/object.rb', line 78 def _contact @_contact ||= && owner && .contact_to!(owner) end |
#_contact_id ⇒ Object
82 83 84 |
# File 'lib/social_stream/models/object.rb', line 82 def _contact_id _contact.try(:id) end |
#_relation_ids ⇒ Object
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/social_stream/models/object.rb', line 86 def _relation_ids @_relation_ids ||= if _contact_id.nil? nil else # FIXME: repeated in Activity#fill_relations if _contact.reflexive? _contact.sender.relation_customs.map(&:id) else _contact. receiver. relation_customs. allow(_contact.sender, 'create', 'activity'). map(&:id) end end end |
#activities ⇒ Object
All the activities with this object
57 58 59 60 61 |
# File 'lib/social_stream/models/object.rb', line 57 def activities Activity. includes(:activity_objects => self.class.to_s.underscore). where("#{ self.class.quoted_table_name }.id" => self.id) end |
#activity_object! ⇒ Object
31 32 33 |
# File 'lib/social_stream/models/object.rb', line 31 def activity_object! activity_object || build_activity_object(:object_type => self.class.to_s) end |
#build_post_activity ⇒ Object
Build the post activity when this object is not saved
64 65 66 67 |
# File 'lib/social_stream/models/object.rb', line 64 def build_post_activity Activity.new :contact_id => _contact_id, :relation_ids => Array(_relation_ids) end |
#create_activity_object_with_type ⇒ Object
Build corresponding ActivityObject including this class type
72 73 74 75 76 |
# File 'lib/social_stream/models/object.rb', line 72 def create_activity_object_with_type #:nodoc: o = create_activity_object! :object_type => self.class.to_s # WEIRD: Rails 3.1.0.rc3 does not assign activity_object_id self.activity_object_id = o.id end |
#represented_author? ⇒ Boolean
Was the author represented with this object was created?
52 53 54 |
# File 'lib/social_stream/models/object.rb', line 52 def == end |
#respond_to?(*args) ⇒ Boolean
ActivityObject handles some methods
47 48 49 |
# File 'lib/social_stream/models/object.rb', line 47 def respond_to? *args super || activity_object!.respond_to?(*args) end |