Module: Streama::Actor

Extended by:
ActiveSupport::Concern
Defined in:
lib/streama/actor.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#activity_classObject


40
41
42
# File 'lib/streama/actor.rb', line 40

def activity_class
  @activity_klass ||= activity_klass ? activity_klass.classify.constantize : ::Activity
end

#activity_stream(options = {}) ⇒ Object


32
33
34
# File 'lib/streama/actor.rb', line 32

def activity_stream(options = {})
  activity_class.stream_for(self, options)
end

#publish_activity(name, options = {}) ⇒ Object

Publishes the activity to the receivers

Examples:

publish an activity with a object and target

current_user.publish_activity(:enquiry, :object => @enquiry, :target => @listing)

Parameters:

  • options (Hash) (defaults to: {})

    The options to publish with.


27
28
29
30
# File 'lib/streama/actor.rb', line 27

def publish_activity(name, options={})
  options[:receivers] = self.send(options[:receivers]) if options[:receivers].is_a?(Symbol)
  activity = activity_class.publish(name, {:actor => self}.merge(options))
end

#published_activities(options = {}) ⇒ Object


36
37
38
# File 'lib/streama/actor.rb', line 36

def published_activities(options = {})
  activity_class.stream_of(self, options)
end