Class: Karafka::Web::Ui::Controllers::Requests::ExecutionWrapper
- Inherits:
-
Object
- Object
- Karafka::Web::Ui::Controllers::Requests::ExecutionWrapper
- Defined in:
- lib/karafka/web/ui/controllers/requests/execution_wrapper.rb
Overview
This class is used internally by the Web UI to wrap controllers and inject execution hooks around any method call (before/after filters).
ExecutionWrapper delegates all method calls to the provided controller instance. Before and after each invocation, it runs the controller’s registered hooks.
This allows for cleaner separation of concerns and reusable hook logic.
Instance Method Summary collapse
-
#initialize(controller) ⇒ ExecutionWrapper
constructor
A new instance of ExecutionWrapper.
-
#method_missing(method_name, *args, &block) ⇒ Object
Delegates any method call to the controller and wraps it with before/after hooks.
-
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
Properly supports respond_to? checks by delegating to the controller.
Constructor Details
#initialize(controller) ⇒ ExecutionWrapper
Returns a new instance of ExecutionWrapper.
22 23 24 |
# File 'lib/karafka/web/ui/controllers/requests/execution_wrapper.rb', line 22 def initialize(controller) @controller = controller end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(method_name, *args, &block) ⇒ Object
Delegates any method call to the controller and wraps it with before/after hooks
32 33 34 35 36 37 |
# File 'lib/karafka/web/ui/controllers/requests/execution_wrapper.rb', line 32 def method_missing(method_name, *args, &block) @controller.run_before_hooks(method_name) result = @controller.public_send(method_name, *args, &block) @controller.run_after_hooks(method_name) result end |
Instance Method Details
#respond_to_missing?(method_name, include_private = false) ⇒ Boolean
Properly supports respond_to? checks by delegating to the controller
44 45 46 |
# File 'lib/karafka/web/ui/controllers/requests/execution_wrapper.rb', line 44 def respond_to_missing?(method_name, include_private = false) @controller.respond_to?(method_name, include_private) end |