Class: Riot::ContextMiddleware
Direct Known Subclasses
Instance Attribute Summary collapse
-
#middleware ⇒ Object
readonly
Theoretically, the next middleware in the stack.
Class Method Summary collapse
-
.register ⇒ Object
Registers the current middleware class with Riot so that it may be included in the set of middlewares Riot will poke before executing a Context.
Instance Method Summary collapse
-
#call(context) ⇒ Object
The meat.
-
#initialize(middleware) ⇒ ContextMiddleware
constructor
A new instance of ContextMiddleware.
Constructor Details
#initialize(middleware) ⇒ ContextMiddleware
Returns a new instance of ContextMiddleware.
19 20 21 |
# File 'lib/riot/middleware.rb', line 19 def initialize(middleware) @middleware = middleware end |
Instance Attribute Details
#middleware ⇒ Object (readonly)
Theoretically, the next middleware in the stack
17 18 19 |
# File 'lib/riot/middleware.rb', line 17 def middleware @middleware end |
Class Method Details
.register ⇒ Object
Registers the current middleware class with Riot so that it may be included in the set of middlewares Riot will poke before executing a Context.
class MyContextMiddleware < Riot::ContextMiddleware
register
def call(context)
context.setup { ... }
middleware.call(context) # this can go anywhere
context.hookup { ... }
end
end
15 |
# File 'lib/riot/middleware.rb', line 15 def self.register; Context.middlewares << self; end |
Instance Method Details
#call(context) ⇒ Object
The meat. Because you have access to the Context, you can add your own setups, hookups, etc. call
will be called before any tests are run, but after the Context is configured.
25 26 27 |
# File 'lib/riot/middleware.rb', line 25 def call(context) raise "You should implement call yourself" end |