Class: Junkfood::Ceb::Executors::DelayedJobCommandExecutorJob

Inherits:
Struct
  • Object
show all
Defined in:
lib/junkfood/ceb/executors/delayed_job_command_executor.rb

Overview

The actual job class that is serialized for DelayedJob runs. which is tasked to perform the commands.

EXPERIMENTAL: This is untested, unfinished code.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#messageObject

Returns the value of attribute message

Returns:

  • (Object)

    the current value of message



29
30
31
# File 'lib/junkfood/ceb/executors/delayed_job_command_executor.rb', line 29

def message
  @message
end

Instance Method Details

#performObject

This method JSON parses the command data, instantiating the referenced Command class, and finally executes the command.



35
36
37
38
39
40
41
# File 'lib/junkfood/ceb/executors/delayed_job_command_executor.rb', line 35

def perform
  params = JSON.parse message
  command_class = params['_type'].constantize
  raise 'err' unless message_class.kind_of? ::Junkfood::Ceb::BaseCommand
  command = command_class.new params
  command.perform
end