-
Notifications
You must be signed in to change notification settings - Fork 1
fix!: Big move to use kwargs as the initializer for classes which include us #28
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
Conversation
There was a problem hiding this 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 changes the way class initialization is handled in the NatsApiServer module, migrating from positional arguments to keyword arguments. The changes ensure that classes including the module must use keyword arguments in their initializers, providing better clarity and type safety.
- Adds validation to ensure
instance_argsis a Hash when provided - Updates the worker instantiation to use keyword argument splat (
**) instead of positional argument splat (*) - Refactors parameter handling in
build_workermethod for consistency
Reviewed Changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| lib/leopard/nats_api_server.rb | Adds Hash validation for instance_args and updates worker instantiation to use keyword arguments |
| lib/leopard/message_wrapper.rb | Adds header assignment in respond method |
| examples/echo_endpoint.rb | Updates example to use keyword arguments and includes debugging code |
Hopefully this doesn't break anything yet, but after
discussing with @BryceARich I changed the way we assume
a class which includes us will define its initializer.
Before we were mandating a simple array of arguments,
this PR will mandate kwargs (Keyword Arguments) only
and raise and ArgumentError in #run if instance_args:
which are not a hash are passed to it.