delayable 0.2.0 → 0.4.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: 22a499788c4598447f63ea0521c8db9c4fd31a6d63a1e823b756a9de205fdb42
4
- data.tar.gz: 556ff5cd6ff684adf1fcc2f84a2ff3840693697972308eba74c415e0b23ff4ad
3
+ metadata.gz: 23e567b9c922ccd54bb09dc460d63597581559481fc136ef3aff722d7294f4e1
4
+ data.tar.gz: e336c91c328a3efa8311d1bb4b8eef85abc0b8138f92ef311f393a65b68360a8
5
5
  SHA512:
6
- metadata.gz: 74ab9e694fecfb0324d41335cec0d429d1b1e0428b529627ade623dbd60ed7917dd5d7c1cfcda2548892bf54a1ea69e0d7639fb26cfa71dccdb4640e3c1392a7
7
- data.tar.gz: 38e2c5cae56572f314b0c4572da14e4052092f037722cd90f03f03109ebc016898bf4a7a9fd5019a5750da693ad021a96f17984cbbc169646b6a6bbf4dfeea9d
6
+ metadata.gz: 4759ae5a84432a6f7a3fa199c05252ebfa21daf06920880c1bbe5ce38aa060b7b5fc78759b3630386d0ba042d58077bc64c10f22ee2069234d9a80b687a6f5c3
7
+ data.tar.gz: '09bfdd9365b70492b8f9d2bee9ae96f775cb36f4d30a5461dca84808cb226be43d809f9f8512cdd0253e697b04907a35bcaef4d41fce8bad8dc942c9d5a16d3f'
data/Rakefile CHANGED
@@ -1,5 +1,8 @@
1
- require "bundler/setup"
2
-
3
- load "rails/tasks/statistics.rake"
1
+ # frozen_string_literal: true
4
2
 
5
3
  require "bundler/gem_tasks"
4
+ require "minitest/test_task"
5
+
6
+ Minitest::TestTask.create
7
+
8
+ task default: :test
@@ -1,3 +1,3 @@
1
1
  module Delayable
2
- VERSION = "0.2.0"
2
+ VERSION = "0.4.0"
3
3
  end
data/lib/delayable.rb CHANGED
@@ -1,8 +1,16 @@
1
+ require "active_support/concern"
2
+ require "active_support/core_ext/string/inflections"
3
+
1
4
  require "delayable/version"
2
5
 
3
6
  module Delayable
4
7
  extend ActiveSupport::Concern
5
8
 
9
+ included do
10
+ fail "Please define ApplicationJob before including Delayable" unless defined?(ApplicationJob)
11
+ fail "Please define Current before including Delayable" unless defined?(Current)
12
+ end
13
+
6
14
  class_methods do
7
15
  def delay(method_name, class_method: false, wait: nil, limits_concurrency: nil, queue: :default)
8
16
  job = const_set(delayable_job_name(method_name, class_method:),
@@ -34,12 +42,18 @@ module Delayable
34
42
  end
35
43
 
36
44
  def delayable_job_name(method_name, class_method: false)
37
- :"#{'Class' if class_method}#{method_name.to_s.camelize}Job"
45
+ class_name = bang_method?(method_name) ? "#{method_name.to_s.chomp('!').camelize}Bang" : method_name.to_s.camelize
46
+ :"#{'Class' if class_method}#{class_name}Job"
38
47
  end
39
48
 
40
49
  def delayable_define_method(class_method:, method_name:, &block)
41
50
  define_method_type = class_method ? :define_singleton_method : :define_method
42
- public_send(define_method_type, "#{method_name}_later", &block)
51
+ method_name = bang_method?(method_name) ? "#{method_name.to_s.chomp('!')}_later!" : "#{method_name}_later"
52
+ public_send(define_method_type, method_name, &block)
53
+ end
54
+
55
+ def bang_method?(method_name)
56
+ method_name.to_s.end_with?('!')
43
57
  end
44
58
  end
45
59
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: delayable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Trae Robrock
8
8
  autorequire:
9
- bindir: bin
9
+ bindir: exe
10
10
  cert_chain: []
11
- date: 2024-10-21 00:00:00.000000000 Z
11
+ date: 2024-10-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails