Skip to content

Add Hookable support to Repository and wrap delegated model calls with hooks#2

Open
bnlucas wants to merge 1 commit intomainfrom
codex/evaluate-adding-rls-dsl-to-repository
Open

Add Hookable support to Repository and wrap delegated model calls with hooks#2
bnlucas wants to merge 1 commit intomainfrom
codex/evaluate-adding-rls-dsl-to-repository

Conversation

@bnlucas
Copy link
Owner

@bnlucas bnlucas commented Dec 25, 2025

Motivation

  • Repositories should support the same hook lifecycle API used by Operation and Flow via Gaskit::Core::Hookable so global/inline hooks can observe repository behavior.
  • Delegated ActiveRecord-like calls need to be able to run before, around, and after hooks to support cross-cutting concerns like metrics and auditing.

Description

  • Include Gaskit::Core::Hookable into Gaskit::Repository and require the hookable helper with require_relative "core/hookable".
  • Wrap delegated model methods in delegate_common_model_methods with hook_runner.apply_hooks(:before, :around, :after) so hooks execute around the model.public_send call.
  • Add a class-level hook_runner helper that allocates a repository instance for running hooks and expose instance helpers logger and model for use inside hooks.
  • Add a spec it "runs hooks around delegated calls" to spec/gaskit/repository_spec.rb that verifies around hooks run surrounding delegated calls.

Testing

  • Added the new spec case in spec/gaskit/repository_spec.rb covering around hooks on delegated methods.
  • Attempted to run the tests with bundle exec rspec spec/gaskit/repository_spec.rb but the environment reported bundler: command not found: rspec, so automated test execution could not be completed.

Codex Task

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant