Skip to content

Conversation

@bougyman
Copy link
Member

@bougyman bougyman commented Aug 7, 2025

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.

Copilot AI review requested due to automatic review settings August 7, 2025 01:53
@bougyman bougyman added the enhancement New feature or request label Aug 7, 2025
@bougyman bougyman self-assigned this Aug 7, 2025
Copy link
Contributor

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 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_args is a Hash when provided
  • Updates the worker instantiation to use keyword argument splat (**) instead of positional argument splat (*)
  • Refactors parameter handling in build_worker method 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

@bougyman bougyman merged commit 72293b4 into main Aug 7, 2025
4 checks passed
@bougyman bougyman deleted the polish-abi branch August 7, 2025 13:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants