mandate-rails 0.2.0 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 68e4e936c75500a7fbc103581cac2254ae15f9eb4bc6d22431a9e62a64c287a3
4
- data.tar.gz: 3747e6670bffa7361a942d759d626aee45704e94bc5f49ba642672d18145eec5
3
+ metadata.gz: 1c5944085c2064c68507785aa26a9e05576522a8b9795df76027af984c689255
4
+ data.tar.gz: f36146618848433239b9c32890a4618f532e9908f1b11446b7dec896920817aa
5
5
  SHA512:
6
- metadata.gz: da59b15511b58a13b2d80c7b2d2522e6e153fe9863ca726253f33aaa3366f11a42127104f39c2ba028710b330047e9f0a626f22fe683d51c1a6d51fa375067db
7
- data.tar.gz: cdd453d68ead9079c3437fa260a95a3dc407694f162bdf1a75837f17e5cda892d366ec228cb02de1109d56d230bf8e8e8271338d19d535ce3288115fb79772cf
6
+ metadata.gz: 1e558be3adabd0ee0c2f5e286c1b9c149056d689d02bc4da80878730d294088a30471c5e25cce0650847e7c363497031e0a55152d4bb918ad5319a59b4a282f6
7
+ data.tar.gz: 64568ac4c34d30f141b381310b1db7ea2d96befd19761ce00bad1d0afe728db69724278994403092470af3055c5bfe086985b8f60a47206119bb7ac3da0ea387
@@ -0,0 +1,46 @@
1
+ require_relative "./mandate_job"
2
+
3
+ module Mandate
4
+ module ActiveJobQueuer
5
+ def self.extended(base)
6
+ class << base
7
+ def queue_as(queue)
8
+ @active_job_queue = queue
9
+ end
10
+
11
+ def active_job_queue
12
+ @active_job_queue || :default
13
+ end
14
+ end
15
+ end
16
+
17
+ def defer(*args, wait: nil, **kwargs)
18
+ # We need to convert the jobs to a hash before we serialize as there's no serialization
19
+ # format for a job. We do this here to avoid cluttering the codebase with this logic.
20
+ if (prereqs = kwargs.delete(:prereq_jobs))
21
+ prereqs.map! do |job|
22
+ {
23
+ job_id: job.provider_job_id,
24
+ queue_name: job.queue_name
25
+ }
26
+ end
27
+ kwargs[:prereq_jobs] = prereqs if prereqs.present?
28
+ end
29
+
30
+ MandateJob.set(
31
+ queue: active_job_queue,
32
+ wait:
33
+ ).perform_later(self.name, *args, **kwargs)
34
+ end
35
+ end
36
+
37
+ def self.included(base)
38
+ # Upstream
39
+ base.extend(Memoize)
40
+ base.extend(CallInjector)
41
+ base.extend(InitializerInjector)
42
+
43
+ # New
44
+ base.extend(ActiveJobQueuer)
45
+ end
46
+ end
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module MandateRails
4
- VERSION = "0.2.0"
4
+ VERSION = "0.3.0"
5
5
  end
@@ -1,9 +1,8 @@
1
1
  require "mandate"
2
- require_relative "rails/version"
3
2
 
4
3
  module MandateRails
5
4
  class Error < StandardError; end
6
5
  # Your code goes here...
7
6
  end
8
7
 
9
- require_relative "./rails/railtie" if defined?(Rails::Railtie)
8
+ require_relative "./mandate-rails/railtie" if defined?(Rails::Railtie)
@@ -1,6 +1,4 @@
1
- # frozen_string_literal: true
2
-
3
- require_relative "lib/mandate/rails/version"
1
+ require_relative "lib/mandate-rails/version"
4
2
 
5
3
  Gem::Specification.new do |spec|
6
4
  spec.name = "mandate-rails"
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mandate-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jeremy Walker
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2024-05-02 00:00:00.000000000 Z
11
+ date: 2024-05-13 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description:
14
14
  email:
@@ -21,13 +21,12 @@ files:
21
21
  - LICENSE.txt
22
22
  - README.md
23
23
  - Rakefile
24
- - lib/mandate/rails.rb
25
- - lib/mandate/rails/active_job_queuer.rb
26
- - lib/mandate/rails/mandate_job.rb
27
- - lib/mandate/rails/railtie.rb
28
- - lib/mandate/rails/version.rb
24
+ - lib/mandate-rails/active_job_queuer.rb
25
+ - lib/mandate-rails/mandate_job.rb
26
+ - lib/mandate-rails/railtie.rb
27
+ - lib/mandate-rails/version.rb
28
+ - lib/mandate_rails.rb
29
29
  - mandate-rails.gemspec
30
- - sig/mandate/rails.rbs
31
30
  homepage:
32
31
  licenses:
33
32
  - MIT
@@ -1,45 +0,0 @@
1
- require_relative "./mandate_job"
2
- module Mandate
3
- module ActiveJobQueuer
4
- def self.extended(base)
5
- class << base
6
- def queue_as(queue)
7
- @active_job_queue = queue
8
- end
9
-
10
- def active_job_queue
11
- @active_job_queue || :default
12
- end
13
- end
14
- end
15
-
16
- def defer(*args, wait: nil, **kwargs)
17
- # We need to convert the jobs to a hash before we serialize as there's no serialization
18
- # format for a job. We do this here to avoid cluttering the codebase with this logic.
19
- if (prereqs = kwargs.delete(:prereq_jobs))
20
- prereqs.map! do |job|
21
- {
22
- job_id: job.provider_job_id,
23
- queue_name: job.queue_name
24
- }
25
- end
26
- kwargs[:prereq_jobs] = prereqs if prereqs.present?
27
- end
28
-
29
- MandateJob.set(
30
- queue: active_job_queue,
31
- wait:
32
- ).perform_later(self.name, *args, **kwargs)
33
- end
34
- end
35
-
36
- def self.included(base)
37
- # Upstream
38
- base.extend(Memoize)
39
- base.extend(CallInjector)
40
- base.extend(InitializerInjector)
41
-
42
- # New
43
- base.extend(ActiveJobQueuer)
44
- end
45
- end
@@ -1,6 +0,0 @@
1
- module Mandate
2
- module Rails
3
- VERSION: String
4
- # See the writing guide of rbs: https://github.com/ruby/rbs#guides
5
- end
6
- end
File without changes