rails_async_methods 0.2.0 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 70a7606803b98d462e11d6de8ee772cf66fd9aa7fe2355a4fc4a315a3b9f6372
4
- data.tar.gz: 0ef6b6034c8096c385aac47a0f1cfe7d65e30480d55dbb22f9035de0ddf6091c
3
+ metadata.gz: aabd842f8437197d8ac4a861a04b3d477c0f9364a7d12584829ee67fbca841ee
4
+ data.tar.gz: 2c4668f5dbef321f07406878bf617038659d77d66f91d8700e5640c9f2824825
5
5
  SHA512:
6
- metadata.gz: d6f9cd94c505732b33480f69ebac5d8700a87227b3dd3f803cf39699f41f98d4397e6229286a6e3da4b08d04636eba028d91c0da31303bfcfe3aa559a642dd90
7
- data.tar.gz: be4580294350b8bc8d2b67f7946a71f7e4f0b16fd5e08ebc472e5f34e4202a0ada9b3133b886a59752fda6075e85953e7e9bc64a44d5df8c68cc55cc10d9b98b
6
+ metadata.gz: c498c7972d6b201e7f87cfd90bff64807850ff62c3483ddaeac61308509891db3c36076e9ce47c217ac249e0d83222e81150dfe3ee370a7fc821f05e4009d48f
7
+ data.tar.gz: 95e44596d54d202f33752b09513f9c313f7825552ba3c19d2d1198cd8dc3fb049644d3adf6070e8b626707c5368db338a67aaa7638b81ef8de57a02328d6d35c
data/README.md CHANGED
@@ -9,6 +9,12 @@ class User
9
9
  # logic...
10
10
  end
11
11
  async :example_method
12
+
13
+ # or...
14
+
15
+ async def example_method2
16
+ # logic...
17
+ end
12
18
  end
13
19
  ```
14
20
  This will give you access to ```user_instance.async_example_method```, which when called will use ActiveJob's API to create an ActiveJob with your backend of choice and call the example_method when the job is ran.
@@ -23,9 +29,9 @@ async :example_method_with_args
23
29
  the ```async_example_method_with_args``` method will have a signature that matches the original method. This makes testing and debugging during development faster, as both sync and async method calls will fail when called with improper arguments instead of silently failing as an active job.
24
30
 
25
31
  ### Object Wrapper
26
- Alternatively, if you don't to declare methods as async in your model, you can utilize the async object wrapper made available globally to all objects.
32
+ Alternatively, if you don't want to declare methods as async in your model, you can utilize the async object wrapper made available globally to all objects.
27
33
  ```ruby
28
- class ResourceController < Application Controller
34
+ class ResourceController < ApplicationController
29
35
  def create
30
36
  async(@resource).any_method_available_to_resource
31
37
  end
@@ -58,7 +64,9 @@ user_instance.asynchronous_example_method
58
64
  - job: use a custom job other than the generated ```RailsAsyncMethods::AbstractJob``` - see section on Custom Jobs below i.e.
59
65
  ```ruby
60
66
  async :example_method, job: CustomExampleMethodJob # defined in model
61
- async(@resource, job: CustomExampleMethodJob).example_method #callable anywhere
67
+ async(@resource, job: CustomExampleMethodJob).example_method # callable anywhere
68
+ @resource.to_active_job(job: CustomExampleMethodJob).example_method
69
+
62
70
  ```
63
71
 
64
72
  - ActiveJob configurations
@@ -9,7 +9,7 @@ module RailsAsyncMethods
9
9
  @prefix = method_prefix(opts[:prefix])
10
10
  @queue = opts[:queue]
11
11
  @wait_until = opts[:wait_until].to_f if opts[:wait_until]
12
- @wait = opts[:wait].seconds.from_now.to_f if opts[:wait]
12
+ @wait = opts[:wait].seconds.to_f if opts[:wait]
13
13
  @priority = opts[:priority].to_i if opts[:priority]
14
14
  @job = get_job_obj(opts[:job])
15
15
  end
@@ -18,7 +18,7 @@ module RailsAsyncMethods
18
18
  active_job_arguments = RailsAsyncMethods::ActiveJobOptionsParser.new(opts)
19
19
 
20
20
  if parsed_method_arguments.empty?
21
- define_method "#{active_job_arguments.prefix.concat(method_name.to_s)}" do
21
+ define_method "#{active_job_arguments.prefix}#{method_name.to_s}" do
22
22
  raise NotPersistedError, 'Instance must be persisted to run asynchronously' unless persisted?
23
23
  raise TypeError, 'Cannot pass a block to an asynchronous method' if block_given?
24
24
 
@@ -43,4 +43,4 @@ module RailsAsyncMethods
43
43
  end
44
44
  end
45
45
  end
46
- end
46
+ end
@@ -1,3 +1,3 @@
1
1
  module RailsAsyncMethods
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.2"
3
3
  end
metadata CHANGED
@@ -1,43 +1,42 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails_async_methods
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - benngarcia
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2022-05-15 00:00:00.000000000 Z
10
+ date: 2025-05-08 00:00:00.000000000 Z
12
11
  dependencies:
13
12
  - !ruby/object:Gem::Dependency
14
- name: rails
13
+ name: activesupport
15
14
  requirement: !ruby/object:Gem::Requirement
16
15
  requirements:
17
16
  - - ">="
18
17
  - !ruby/object:Gem::Version
19
- version: 7.0.2.4
18
+ version: '0'
20
19
  type: :runtime
21
20
  prerelease: false
22
21
  version_requirements: !ruby/object:Gem::Requirement
23
22
  requirements:
24
23
  - - ">="
25
24
  - !ruby/object:Gem::Version
26
- version: 7.0.2.4
25
+ version: '0'
27
26
  - !ruby/object:Gem::Dependency
28
- name: activesupport
27
+ name: rails
29
28
  requirement: !ruby/object:Gem::Requirement
30
29
  requirements:
31
30
  - - ">="
32
31
  - !ruby/object:Gem::Version
33
- version: '0'
32
+ version: 7.0.2.4
34
33
  type: :runtime
35
34
  prerelease: false
36
35
  version_requirements: !ruby/object:Gem::Requirement
37
36
  requirements:
38
37
  - - ">="
39
38
  - !ruby/object:Gem::Version
40
- version: '0'
39
+ version: 7.0.2.4
41
40
  - !ruby/object:Gem::Dependency
42
41
  name: minitest
43
42
  requirement: !ruby/object:Gem::Requirement
@@ -120,7 +119,6 @@ licenses:
120
119
  metadata:
121
120
  homepage_uri: https://github.com/benngarcia/rails_async_methods
122
121
  changelog_uri: https://github.com/benngarcia/rails_async_methods/blob/master/CHANGELOG.md
123
- post_install_message:
124
122
  rdoc_options: []
125
123
  require_paths:
126
124
  - lib
@@ -135,8 +133,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
135
133
  - !ruby/object:Gem::Version
136
134
  version: '0'
137
135
  requirements: []
138
- rubygems_version: 3.3.3
139
- signing_key:
136
+ rubygems_version: 3.6.2
140
137
  specification_version: 4
141
138
  summary: Quickly, create async callers and receivers for your rails methods, because
142
139
  y'know DRY.