Skip to content

Extra components #66

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Jun 23, 2025
Merged

Extra components #66

merged 4 commits into from
Jun 23, 2025

Conversation

GrantBirki
Copy link
Member

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.

- 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.
@Copilot Copilot AI review requested due to automatic review settings June 23, 2025 21:26
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 GlobalComponents to register, retrieve, inspect, reset, and thread-safely manage extra components.
  • Updated ComponentAccess to dynamically expose user components via method_missing and respond_to_missing?.
  • Modified Builder and Hooks.build to 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

@GrantBirki GrantBirki merged commit bd87347 into main Jun 23, 2025
22 checks passed
@GrantBirki GrantBirki deleted the extra-components branch June 23, 2025 21:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant