Module: BatchKit::ActsAsSequence

Defined in:
lib/batch-kit/framework/acts_as_sequence.rb

Overview

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:

  • desc A method for setting a description for a subsequent sequence

  • sequence Defines a sequence entry method

  • sequence_definition Returns the Sequence::Definition object for the including class

  • on_success defines a callback to be called if the sequence completes successfully.

  • 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.

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(base) ⇒ Object

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.



94
95
96
97
98
99
100
# 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

Instance Method Details

#parallelObject



103
104
105
106
# File 'lib/batch-kit/framework/acts_as_sequence.rb', line 103

def parallel
    # TODO: Implement running contents of block in parallel
    yield
end

#sequenceSequence::Definition

Returns The SequenceDefinition for this Sequence instance.

Returns:



110
111
112
# File 'lib/batch-kit/framework/acts_as_sequence.rb', line 110

def sequence
    self.class.sequence_definition
end

#sequence_runSequence::Run

Returns The SequenceRun for this Sequence instance.

Returns:

  • (Sequence::Run)

    The SequenceRun for this Sequence instance.



116
117
118
# File 'lib/batch-kit/framework/acts_as_sequence.rb', line 116

def sequence_run
    @__sequence_run__
end