Sha256: 6e6d816b29d226133e87d68ace329e4dec7885dce26388027efc7094e21a3824
Contents?: true
Size: 948 Bytes
Versions: 1
Compression:
Stored size: 948 Bytes
Contents
module Elevate def self.included(base) base.extend(ClassMethods) end module ClassMethods def task(name, options = {}, &block) task_definitions[name.to_sym] = TaskDefinition.new(name.to_sym, options, &block) end def task_definitions @task_definitions ||= {} end end def cancel(name) active_tasks.each do |task| if task.name == name task.cancel end end end def cancel_all active_tasks.each do |task| task.cancel end end def launch(name, args = {}) raise ArgumentError, "args must be a Hash" unless args.is_a? Hash definition = self.class.task_definitions[name.to_sym] task = Task.new(definition, self, active_tasks) task.start(args) task end def task_args @__elevate_task_args end def task_args=(args) @__elevate_task_args = args end private def active_tasks @__elevate_active_tasks ||= [] end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
elevate-0.7.0 | lib/elevate/elevate.rb |