lib/arsenicum/task.rb in arsenicum-0.0.1 vs lib/arsenicum/task.rb in arsenicum-0.1.0
- old
+ new
@@ -1,53 +1,13 @@
-require 'json'
+class Arsenicum::Task
+ attr_reader :id
-module Arsenicum
- class Task
- include Serialization
+ def initialize(id)
+ @id = id
+ end
- attr_reader :target, :method, :arguments, :timestamp, :message_id, :exception
-
- def self.parse(raw_message, message_id)
- message_content = JSON(raw_message)
-
- timestamp = message_content['timestamp']
- method = message_content['method_name'].to_sym
-
- target = restore(message_content['target'])
- arguments = message_content['arguments'].nil? ? [] :
- message_content['arguments'].map{|arg|restore(arg)}
-
- new(target, method, arguments, timestamp, message_id)
- end
-
- def initialize(target, method, arguments, timestamp, message_id)
- @target = target
- @method = method
- @arguments = arguments
- @timestamp = timestamp
- @message_id = message_id
- end
-
- def prepare_serialization
- {
- target: prepare_serialization(target),
- timestamp: (Time.now.to_f * 1000000).to_i,
- method_name: method_name,
- arguments: arguments.nil? ? nil : arguments.map{|arg|prepare_serialization(arg)},
- }
- end
-
- def serialize
- JSON(prepare_serialization)
- end
-
- def execute!
- target.__send__ method, *arguments
- rescue Exception => e
- @exception = e
- end
-
- def successful?
- !exception
- end
+ def run(*parameters)
+ # Originally do nothing. This will be overridden in the derived classes.
end
-end
+
+ autoload :ClassDispatcher, 'arsenicum/task/class_dispatcher'
+end
\ No newline at end of file