Module: Streama::Activity
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/streama/activity.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
-
#load_instance(type) ⇒ Mongoid::Document
Returns an instance of an actor, object or target.
-
#publish(options = {}) ⇒ Object
Publishes the activity to the receivers.
- #refresh_data ⇒ Object
Instance Method Details
#load_instance(type) ⇒ Mongoid::Document
Returns an instance of an actor, object or target
89 90 91 |
# File 'lib/streama/activity.rb', line 89 def load_instance(type) (data = self.send(type)).is_a?(Hash) ? data['type'].to_s.camelcase.constantize.find(data['id']) : data end |
#publish(options = {}) ⇒ Object
Publishes the activity to the receivers
77 78 79 80 81 82 |
# File 'lib/streama/activity.rb', line 77 def publish( = {}) actor = load_instance(:actor) self.receivers = ([:receivers] || actor.followers).map { |r| { :id => r.id, :type => r.class.to_s } } self.save self end |
#refresh_data ⇒ Object
93 94 95 96 |
# File 'lib/streama/activity.rb', line 93 def refresh_data assign_data save(:validate => false) end |