Sha256: 8042d42253cdca0ba681185a839a8930105ebc1dba48827e7e746f933f1fdd05

Contents?: true

Size: 725 Bytes

Versions: 1

Compression:

Stored size: 725 Bytes

Contents

require 'tap/app'

module Tap
  class Middleware < App::Api
    class << self
      def build(spec={}, app=Tap::App.instance)
        new(app.stack, spec['config'] || {})
      end
    end
    
    # The call stack.
    attr_reader :stack

    def initialize(stack, config={})
      @stack = stack
      initialize_config(config)
    end
    
    # Returns the app at the base of the stack.
    def app
      @app ||= begin
        current = stack
        until current.kind_of?(App::Stack)
          current = current.stack
        end
        current.app
      end
    end
    
    # By default call simply calls stack with the node and inputs.
    def call(node, inputs=[])
      stack.call(node, inputs)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tap-0.19.0 lib/tap/middleware.rb