Class: Activr::Async::Resque::TimelineHandle

Inherits:
Object
  • Object
show all
Defined in:
lib/activr/async/resque.rb

Overview

Class to handle :timeline_handle hook thanks to a Resque job

Class Method Summary collapse

Class Method Details

.enqueue(timeline, activity, route) ⇒ Object

Enqueue job



36
37
38
# File 'lib/activr/async/resque.rb', line 36

def enqueue(timeline, activity, route)
  ::Resque.enqueue(self, timeline.kind, timeline.recipient_id, activity.to_hash, route.kind)
end

.perform(timeline_kind, recipient_id, activity_hash, route_kind) ⇒ Object

Perform job



41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'lib/activr/async/resque.rb', line 41

def perform(timeline_kind, recipient_id, activity_hash, route_kind)
  # unserialize arguments
  recipient_id = Activr.storage.unserialize_id_if_necessary(recipient_id)
  activity_hash = Activr::Activity.unserialize_hash(activity_hash)

  timeline_klass = Activr.registry.class_for_timeline(timeline_kind)

  timeline = timeline_klass.new(recipient_id)
  activity = Activr::Activity.from_hash(activity_hash)
  route    = timeline_klass.route_for_kind(route_kind)

  # call hook
  Activr::Async.timeline_handle(timeline, activity, route)
end