class Elevate::TaskDefinition
Attributes
handlers[R]
name[R]
options[R]
Public Class Methods
new(name, options, &block)
click to toggle source
# File lib/elevate/task_definition.rb, line 3 def initialize(name, options, &block) @name = name @options = options @handlers = {} instance_eval(&block) end
Public Instance Methods
background(&block)
click to toggle source
# File lib/elevate/task_definition.rb, line 30 def background(&block) @handlers[:background] = block end
method_missing(method, *args, &block)
click to toggle source
Calls superclass method
# File lib/elevate/task_definition.rb, line 15 def method_missing(method, *args, &block) if method.to_s.start_with?("on_") raise ArgumentError, "wrong number of arguments" unless args.empty? raise ArgumentError, "block not supplied" unless block_given? @handlers[method.to_sym] = block else super end end
on_error(&block)
click to toggle source
# File lib/elevate/task_definition.rb, line 34 def on_error(&block) raise "on_error blocks must accept one parameter" unless block.arity == 1 @handlers[:on_error] = block end
on_finish(&block)
click to toggle source
# File lib/elevate/task_definition.rb, line 40 def on_finish(&block) raise "on_finish blocks must accept two parameters" unless block.arity == 2 @handlers[:on_finish] = block end
on_start(&block)
click to toggle source
# File lib/elevate/task_definition.rb, line 46 def on_start(&block) raise "on_start blocks must accept zero parameters" unless block.arity == 0 @handlers[:on_start] = block end
on_update(&block)
click to toggle source
# File lib/elevate/task_definition.rb, line 52 def on_update(&block) @handlers[:on_update] = block end
respond_to_missing?(method, include_private = false)
click to toggle source
Calls superclass method
# File lib/elevate/task_definition.rb, line 26 def respond_to_missing?(method, include_private = false) method.to_s.start_with?("on_") || super end
timeout(seconds)
click to toggle source
# File lib/elevate/task_definition.rb, line 56 def timeout(seconds) raise "timeout argument must be a number" unless seconds.is_a?(Numeric) @options[:timeout_interval] = seconds end