Module: Trailblazer::Operation::Worker

Defined in:
lib/trailblazer/operation/worker.rb

Overview

only kicks in when Operation::run, #run will still do it real-time

Defined Under Namespace

Modules: ClassMethods, FileMarshaller

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object



9
10
11
12
# File 'lib/trailblazer/operation/worker.rb', line 9

def self.included(base)
  base.send(:include, Sidekiq::Worker) # TODO: this will work with any bg gem.
  base.extend(ClassMethods)
end

Instance Method Details

#perform(params) ⇒ Object

called from Sidekiq.



36
37
38
39
40
41
42
43
44
45
# File 'lib/trailblazer/operation/worker.rb', line 36

def perform(params)
  # the serialized params hash from Sidekiq contains a Op::UploadedFile hash.

  # the following code is basically what happens in a controller.
  # this is a bug in Rails, it doesn't work without requiring as/hash/ina
  # params = ActiveSupport::HashWithIndifferentAccess.new_from_hash_copying_default(params) # TODO: this might make it ultra-slow as Reform converts it back to strings.
  params = params.with_indifferent_access

  run(deserializable(params))
end