Class: BackgroundLite::RunnerHandler

Inherits:
Object
  • Object
show all
Defined in:
lib/background_lite/core_ext/handlers/runner_handler.rb

Overview

This background handler runs the method block via script/runner.

Class Method Summary collapse

Class Method Details

.execute(object, method, args) ⇒ Object

Executes an encoded message which was sent via command line to runner



14
15
16
17
18
19
20
# File 'lib/background_lite/core_ext/handlers/runner_handler.rb', line 14

def self.execute(object, method, args)
  object, args = self.decode(object), self.decode(args)
  puts "--- executing method: #{method}\n--- with variables: #{args.inspect}\n--- in object: #{object.inspect}"
  
  object.send(method, *args)
  puts "--- it happened!"
end

.handle(object, method, args, options = {}) ⇒ Object

Marshals the method and arguments and sends them to script/runner.



7
8
9
10
11
# File 'lib/background_lite/core_ext/handlers/runner_handler.rb', line 7

def self.handle(object, method, args, options = {})
  fork do
    system(%{script/runner "BackgroundLite::RunnerHandler.execute '#{encode(object)}', '#{method}', '#{encode(args)}'"})
  end
end