Module: Otto::Core::HelperRegistry
- Included in:
- Otto
- Defined in:
- lib/otto/core/helper_registry.rb
Overview
Helper registration module for extending Otto’s Request and Response classes. Provides the public API for registering custom helper modules.
Instance Method Summary collapse
-
#register_request_helpers(*modules) ⇒ Object
Register request helper modules.
-
#register_response_helpers(*modules) ⇒ Object
Register response helper modules.
-
#registered_request_helpers ⇒ Array<Module>
private
Get registered request helper modules (for debugging).
-
#registered_response_helpers ⇒ Array<Module>
private
Get registered response helper modules (for debugging).
Instance Method Details
#register_request_helpers(*modules) ⇒ Object
Register request helper modules
Registered modules are included in Otto::Request at the class level, making custom helpers available alongside Otto’s built-in helpers. Must be called before first request (before configuration freezing).
This is the official integration point for application-specific helpers that work with Otto internals (strategy_result, privacy features, etc.).
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
# File 'lib/otto/core/helper_registry.rb', line 35 def register_request_helpers(*modules) begin ensure_not_frozen! rescue FrozenError raise FrozenError, 'Cannot register request helpers after first request' end modules.each do |mod| unless mod.is_a?(Module) raise ArgumentError, "Expected Module, got #{mod.class}" end @request_helper_modules << mod unless @request_helper_modules.include?(mod) end # Re-finalize to include newly registered helpers finalize_request_response_classes end |
#register_response_helpers(*modules) ⇒ Object
Register response helper modules
Registered modules are included in Otto::Response at the class level, making custom helpers available alongside Otto’s built-in helpers. Must be called before first request (before configuration freezing).
73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 |
# File 'lib/otto/core/helper_registry.rb', line 73 def register_response_helpers(*modules) begin ensure_not_frozen! rescue FrozenError raise FrozenError, 'Cannot register response helpers after first request' end modules.each do |mod| unless mod.is_a?(Module) raise ArgumentError, "Expected Module, got #{mod.class}" end @response_helper_modules << mod unless @response_helper_modules.include?(mod) end # Re-finalize to include newly registered helpers finalize_request_response_classes end |
#registered_request_helpers ⇒ Array<Module>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Get registered request helper modules (for debugging)
95 96 97 |
# File 'lib/otto/core/helper_registry.rb', line 95 def registered_request_helpers @request_helper_modules.dup end |
#registered_response_helpers ⇒ Array<Module>
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Get registered response helper modules (for debugging)
103 104 105 |
# File 'lib/otto/core/helper_registry.rb', line 103 def registered_response_helpers @response_helper_modules.dup end |