Class: Makit::Commands::Middleware::Base
- Inherits:
-
Object
- Object
- Makit::Commands::Middleware::Base
- Defined in:
- lib/makit/commands/middleware/base.rb
Overview
Base class for all command execution middleware.
Middleware provides a way to add cross-cutting concerns like logging, caching, validation, and timing to command execution without modifying the core execution logic.
Direct Known Subclasses
Instance Method Summary collapse
-
#applicable?(_request) ⇒ Boolean
Check if this middleware should be applied to the given request.
-
#call(request) {|Request| ... } ⇒ Result
Execute middleware logic.
-
#config ⇒ Hash
Get middleware configuration.
-
#name ⇒ String
Get middleware name for logging and debugging.
Instance Method Details
#applicable?(_request) ⇒ Boolean
Check if this middleware should be applied to the given request.
Override this method to provide conditional middleware application based on request properties.
51 52 53 |
# File 'lib/makit/commands/middleware/base.rb', line 51 def applicable?(_request) true end |
#call(request) {|Request| ... } ⇒ Result
Execute middleware logic.
This method must be implemented by subclasses to provide the actual middleware functionality. The pattern is to perform any pre-execution logic, call the block to continue the middleware chain, then perform any post-execution logic.
40 41 42 |
# File 'lib/makit/commands/middleware/base.rb', line 40 def call(request, &block) raise NotImplementedError, "#{self.class.name} must implement #call" end |
#config ⇒ Hash
Get middleware configuration.
Override this method to provide middleware-specific configuration.
67 68 69 |
# File 'lib/makit/commands/middleware/base.rb', line 67 def config {} end |
#name ⇒ String
Get middleware name for logging and debugging.
58 59 60 |
# File 'lib/makit/commands/middleware/base.rb', line 58 def name self.class.name.split("::").last end |