Class: Tap::Middleware

Inherits:
App::Api show all
Defined in:
lib/tap/middleware.rb

Direct Known Subclasses

Tap::Middlewares::Debugger

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from App::Api

#associations, help, inherited, #inspect, parse, parse!, parser, #to_spec

Methods included from Signals

#sig, #signal, #signal?, #signals

Methods included from Signals::ModuleMethods

included

Constructor Details

#initialize(stack, config = {}) ⇒ Middleware

Returns a new instance of Middleware.



14
15
16
17
# File 'lib/tap/middleware.rb', line 14

def initialize(stack, config={})
  @stack = stack
  initialize_config(config)
end

Instance Attribute Details

#stackObject (readonly)

The call stack.



12
13
14
# File 'lib/tap/middleware.rb', line 12

def stack
  @stack
end

Class Method Details

.build(spec = {}, app = Tap::App.current) ⇒ Object



6
7
8
# File 'lib/tap/middleware.rb', line 6

def build(spec={}, app=Tap::App.current)
  new(app.stack, spec['config'] || {})
end

Instance Method Details

#appObject

Returns the app at the base of the stack.



20
21
22
23
24
25
26
27
28
# File 'lib/tap/middleware.rb', line 20

def app
  @app ||= begin
    current = stack
    until current.kind_of?(App::Stack)
      current = current.stack
    end
    current.app
  end
end

#call(task, input) ⇒ Object

By default call simply calls stack with the task and inputs.



31
32
33
# File 'lib/tap/middleware.rb', line 31

def call(task, input)
  stack.call(task, input)
end