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 shorts in each WORKFLOW_FLAGS.

configurations.values.collect {|config| config.attributes[:short] }

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ Join

Initializes a new join with the specified configuration.



49
50
51
# File 'lib/tap/support/join.rb', line 49

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>”



73
74
75
# File 'lib/tap/support/join.rb', line 73

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)


61
62
63
# File 'lib/tap/support/join.rb', line 61

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



55
56
57
# File 'lib/tap/support/join.rb', line 55

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

#optionsObject

A hash of the configurations set to true.



66
67
68
69
70
# File 'lib/tap/support/join.rb', line 66

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