lib/pigeon/task.rb in pigeon-0.9.3 vs lib/pigeon/task.rb in pigeon-1.0.0
- old
+ new
@@ -1,6 +1,11 @@
class Pigeon::Task
+ # == Exceptions ===========================================================
+
+ class EngineRequired < StandardError
+ end
+
# == Constants ============================================================
# == Properties ===========================================================
attr_reader :state
@@ -33,9 +38,13 @@
# the context property.
def initialize(context = nil, engine = nil)
@context = context
@engine = engine || Pigeon::Engine.default_engine
@created_at = Time.now
+
+ unless (@engine)
+ raise EngineRequired, "Task creation requires an active Pigeon::Engine"
+ end
after_initialized
end
# Kicks off the task. The processor execurting the task should be supplied