From f880222e11178f930afaf9bd311777059c1e59c4 Mon Sep 17 00:00:00 2001 From: Mark Burns Date: Tue, 2 Jul 2024 20:20:50 +0100 Subject: [PATCH] document changes --- CHANGELOG.md | 1 + lib/interactify.rb | 17 ++++++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 89ad248..fcea518 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,5 @@ ## [Unreleased] +- Add support for `Interactify.with(queue: 'within_30_seconds', retry: 3)` ## [0.5.0] - 2024-01-01 - Add support for `SetA = Interactify { _1.a = 'a' }`, lambda and block class creation syntax diff --git a/lib/interactify.rb b/lib/interactify.rb index d3124e8..fe18afb 100644 --- a/lib/interactify.rb +++ b/lib/interactify.rb @@ -39,8 +39,12 @@ def included(base) # expect :foo # end # - # ExampleInteractor::Job is a class availabe to be used in a sidekiq yaml file - # ExampleInteractor::Async.call(foo: 'bar') # uses the within_30_seconds queue + # creates + # - ExampleInteractor::InteractifyWithOptions + # - ExampleInteractor::JobWith__Queue_Within30Seconds__Retries_3 + # - ExampleInteractor::Job (an alias of above) + # - ExampleInteractor::AsyncWith__Queue_Within30Seconds__Retries_3 + # - ExampleInteractor::Async (an alias of above) def with(receiver, sidekiq_opts = {}) sidekiq_opts = sidekiq_opts.symbolize_keys klass_name = Async::JobMaker::VALID_KEYS.map do |key| @@ -57,15 +61,22 @@ def with(receiver, sidekiq_opts = {}) receiver.const_set(:InteractifyWithOptions, Module.new) mod = receiver.const_get(:InteractifyWithOptions) + job_klass = nil + async_klass = nil + mod.instance_eval do define_singleton_method :included do |base| base.include Interactify::Core base.include Interactify::Async::Jobable - base.interactor_job(opts: sidekiq_opts, klass_suffix:) + job_klass = base.interactor_job(opts: sidekiq_opts, klass_suffix:) + async_klass = base::Async.const_get("Async#{klass_suffix}") end end + receiver.const_set("Job", job_klass) + receiver.const_set("Async", async_klass) + mod end end