Class: Tap::Support::Join

Inherits:
Object show all
Includes:
Configurable
Defined in:
lib/tap/support/join.rb

Overview

Joins create on_complete blocks which link together tasks (or more generally, Executable objects) into workflows. Joins support a variety of configurations which affect how one task passes inputs to subsequent tasks.

Joins have a single source and may have multiple targets. See ReverseJoin for joins with a single target and multiple sources.

Constant Summary collapse

FLAGS =

An array of workflow flags. Workflow flags are false unless specified.

configurations.keys
SHORT_FLAGS =

An array of the first character in each WORKFLOW_FLAGS.

FLAGS.collect {|flag| flag.to_s[0,1]}

Instance Attribute Summary

Attributes included from Configurable

#config

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Configurable

included, #initialize_copy, #reconfigure

Constructor Details

#initialize(config) ⇒ Join

Initializes a new join with the specified configuration.



45
46
47
# File 'lib/tap/support/join.rb', line 45

def initialize(config)
  initialize_config(config)
end

Class Method Details

.join(source, targets, &block) ⇒ Object

Create a join between the source and targets. Targets should be an array; if the last member of targets is a hash, it will be used as the configurations for the join.



17
18
19
20
# File 'lib/tap/support/join.rb', line 17

def join(source, targets, &block)
  options = targets[-1].kind_of?(Hash) ? targets.pop : {}
  new(options).join(source, targets, &block)
end

Instance Method Details

#inspectObject

Returns a string like: “#<Join:object_id>”



69
70
71
# File 'lib/tap/support/join.rb', line 69

def inspect
  "#<Join:#{object_id}>"
end

#join(source, targets, &block) ⇒ Object

Creates a join between the source and targets. Must be implemented in subclasses.

Raises:

  • (NotImplementedError)


57
58
59
# File 'lib/tap/support/join.rb', line 57

def join(source, targets, &block)
  raise NotImplementedError
end

#nameObject

The name of the join, as a symbol. By default name is the basename of the underscored class.



51
52
53
# File 'lib/tap/support/join.rb', line 51

def name
  File.basename(self.class.to_s.underscore).to_sym
end

#optionsObject

A hash of the configurations set to true.



62
63
64
65
66
# File 'lib/tap/support/join.rb', line 62

def options
  opts = config.to_hash
  opts.delete_if {|key, value| value == false }
  opts
end