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.
6 7 8 9 10 11 12 |
# File 'lib/modware/stack.rb', line 6 def initialize(env:) @env_klass = case env when Class then env else KeyStruct[*env] end @middleware_mods = [] end |
Instance Method Details
#add(mod) ⇒ Object
14 15 16 |
# File 'lib/modware/stack.rb', line 14 def add(mod) @middleware_mods << mod end |
#start(*args, &base_implementation) ⇒ Object
18 19 20 21 22 |
# File 'lib/modware/stack.rb', line 18 def start(*args, &base_implementation) env = @env_klass.new(*args) Executor.new(@middleware_mods).execute(env, base_implementation) env end |