module BatchKit::ActsAsSequence
When included into a class, marks the class as a BatchKit
sequence. The including class has the following class methods added, which act as a DSL for specifying the sequence properties and behaviour:
-
{ClassMethods#desc desc} A method for setting a description for a subsequent sequence
-
{ClassMethods#sequence sequence} Defines a sequence entry method
-
{ClassMethods#sequence_definition sequence_definition} Returns the
Sequence::Definition
object for the including class -
{ClassMethods#on_success on_success} defines a callback to be called if the sequence completes successfully.
-
{ClassMethods#on_failure on_failure} defines a callback to be called if the sequence encounters an unhandled exception.
Instances of the including class also get the following instance methods:
-
{#sequence} Returns the
Sequence::Definition
for the class -
{#sequence_run} Returns the
Sequence::Run
associated with this object instance.
Public Class Methods
Hook used to extend the including class with class methods defined in the ActsAsSequence::ClassMethods
module.
Creates a Sequence::Definition
object to hold details of the sequence, and stores it away in a @__sequence__ class instance variable.
# File lib/batch-kit/framework/acts_as_sequence.rb, line 94 def self.included(base) base.extend(ClassMethods) caller.find{ |f| !(f =~ /batch.framework/) } =~ /^((?:[a-zA-Z]:)?[^:]+)/ sequence_file = File.realpath($1) sequence_defn = Sequence::Definition.new(base, sequence_file) base.instance_variable_set :@__sequence__, sequence_defn end
Public Instance Methods
# File lib/batch-kit/framework/acts_as_sequence.rb, line 103 def parallel # TODO: Implement running contents of block in parallel yield end
@return [Sequence::Definition] The SequenceDefinition for this Sequence
instance.
# File lib/batch-kit/framework/acts_as_sequence.rb, line 110 def sequence self.class.sequence_definition end
@return [Sequence::Run] The SequenceRun for this Sequence
instance.
# File lib/batch-kit/framework/acts_as_sequence.rb, line 116 def sequence_run @__sequence_run__ end