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
88 89 90 |
# File 'lib/streama/activity.rb', line 88 def load_instance(type) (data = self.read_attribute(type)).is_a?(Hash) ? data['type'].to_s.camelcase.constantize.find(data['id']) : data end |
#publish(options = {}) ⇒ Object
Publishes the activity to the receivers
76 77 78 79 80 81 |
# File 'lib/streama/activity.rb', line 76 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
92 93 94 95 |
# File 'lib/streama/activity.rb', line 92 def refresh_data assign_data save(:validates_presence_of => false) end |