Extra components#66
Merged
Merged
Conversation
- Added ExamplePublisher class to demonstrate custom component usage. - Updated Hooks.build method to accept arbitrary user-defined components. - Enhanced GlobalComponents for registration and retrieval of user components. - Improved ComponentAccess module to allow dynamic access to user-defined components. - Added tests for user component registration and access in various contexts. - Introduced new acceptance tests for /webhooks/hello endpoint.
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR adds support for user-defined components in the Hooks framework, letting consumers register arbitrary services at startup and access them in handler plugins.
- Extended
GlobalComponentsto register, retrieve, inspect, reset, and thread-safely manage extra components. - Updated
ComponentAccessto dynamically expose user components viamethod_missingandrespond_to_missing?. - Modified
BuilderandHooks.buildto accept and propagate**extra_components, and updated docs, examples, and tests accordingly.
Reviewed Changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| spec/unit/lib/hooks/core/global_components_spec.rb | Added tests for registration, retrieval, inspection, reset, and concurrency |
| spec/unit/lib/hooks/core/component_access_spec.rb | Added specs for dynamic user-component access and method behavior |
| spec/unit/lib/hooks/core/builder_spec.rb | Added tests for builder initialization and build behavior with extras |
| spec/unit/hooks_spec.rb | Added tests for passing extras through Hooks.build |
| spec/acceptance/plugins/handlers/hello.rb | Updated example handler to use the new publisher component |
| spec/acceptance/acceptance_tests.rb | Added acceptance test for the /webhooks/hello endpoint |
| lib/hooks/core/global_components.rb | Implemented extra-component registry with thread safety |
| lib/hooks/core/component_access.rb | Extended module to handle user-defined components dynamically |
| lib/hooks/core/builder.rb | Updated initializer and build to accept and register extras |
| lib/hooks.rb | Updated Hooks.build signature to forward extras |
| docs/handler_plugins.md | Added “Extra Components” documentation and usage example |
| config.ru | Provided a runnable example with extra components |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces support for user-defined components in the Hooks framework, allowing developers to pass custom components to the application and access them globally within handler plugins. The changes include updates to the core framework, documentation, and tests to support this new functionality.