Sha256: 80cbd79d8bb41cc66152843d127b80dca77387c0b26fc7c5146408822683e1df

Contents?: true

Size: 1.25 KB

Versions: 2

Compression:

Stored size: 1.25 KB

Contents

module Tap
  class App
    
    # Node adds the node API[link:files/doc/API.html] to objects responding
    # to call.  Additional helper methods are added to simplify the
    # construction of workflows; they are not required by the API.
    module Node

      # The joins called when call completes
      attr_accessor :joins
      
      # An array of node dependencies
      attr_reader :dependencies
      
      # Interns a new node by extending the block with Node. 
      def self.intern(&block)
        block.extend self
      end
      
      # Sets up required variables for extended objects.
      def self.extended(obj) # :nodoc:
        obj.instance_variable_set(:@joins, [])
        obj.instance_variable_set(:@dependencies, [])
      end
      
      # Sets the block as a join for self.
      def on_complete(&block) # :yields: result
        self.joins << block if block
        self
      end
      
      # Adds the dependency to self.  Dependencies are resolved by an app
      # during App#dispatch and must be valid nodes.
      def depends_on(dependency)
        raise "cannot depend on self" if dependency == self
        unless dependencies.include?(dependency)
          dependencies << dependency
        end
        self
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
tap-0.17.1 lib/tap/app/node.rb
tap-0.17.0 lib/tap/app/node.rb