Class: Tap::Middleware
Direct Known Subclasses
Instance Attribute Summary collapse
-
#stack ⇒ Object
readonly
The call stack.
Class Method Summary collapse
Instance Method Summary collapse
-
#app ⇒ Object
Returns the app at the base of the stack.
-
#call(task, input) ⇒ Object
By default call simply calls stack with the task and inputs.
-
#initialize(stack, config = {}) ⇒ Middleware
constructor
A new instance of Middleware.
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
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
#stack ⇒ Object (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
#app ⇒ Object
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 |