Class: Smooth::Command::AsyncWorker

Inherits:
Object
  • Object
show all
Defined in:
lib/smooth/command/async_worker.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.options(*args) ⇒ Object



7
8
9
# File 'lib/smooth/command/async_worker.rb', line 7

def self.options(*args)
  send(:sidekiq_options, *args) if defined?(Sidekiq)
end

Instance Method Details

#memory_storeObject



23
24
25
# File 'lib/smooth/command/async_worker.rb', line 23

def memory_store
  Smooth.config.memory_store
end

#perform(serialized_payload) ⇒ Object



11
12
13
14
15
16
17
18
19
20
21
# File 'lib/smooth/command/async_worker.rb', line 11

def perform(serialized_payload)
  if hash = memory_store.read(serialized_payload)
    api, object_path, payload = hash.values_at('api', 'object_path', 'payload')
    current_user = payload['current_user'] || hash['current_user']

    chain = Smooth(api).lookup_object_by(object_path)
    chain = chain.as(current_user) if current_user

    chain.run(payload)
  end
end