Class: Modware::Stack
- Inherits:
-
Object
- Object
- Modware::Stack
- Defined in:
- lib/modware/stack.rb
Defined Under Namespace
Classes: Executor, Middleware
Instance Method Summary collapse
- #add(mod) ⇒ Object
-
#initialize(env:) ⇒ Stack
constructor
A new instance of Stack.
- #start(*args, &base_implementation) ⇒ Object
Constructor Details
#initialize(env:) ⇒ Stack
Returns a new instance of Stack.
5 6 7 8 9 10 11 |
# File 'lib/modware/stack.rb', line 5 def initialize(env:) @env_klass = case env when Class then env else KeyStruct[*env] end @middleware_mods = [] end |
Instance Method Details
#add(mod) ⇒ Object
13 14 15 |
# File 'lib/modware/stack.rb', line 13 def add(mod) @middleware_mods << mod end |
#start(*args, &base_implementation) ⇒ Object
17 18 19 20 21 |
# File 'lib/modware/stack.rb', line 17 def start(*args, &base_implementation) env = @env_klass.new(*args) Executor.new(@middleware_mods).execute(env, base_implementation) env end |