operationable 0.5.0 → 0.5.5

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: 41bca9e0252a8203e034c1062d456aeedf44281b5b0690932e19e07c02333b5e
4
- data.tar.gz: 296512c2beda9e26c82d644a38bc7f2e02867e6d93be0232930baef7e4afb7c0
3
+ metadata.gz: 6edf66c7b75e60f58aa296b89200a5e19d19628c0b8d80b54369fb40cf5f232c
4
+ data.tar.gz: 60ac229144e1f919746746e86d7cdd373cb6aa619c81d650e13c64e8f3874a1f
5
5
  SHA512:
6
- metadata.gz: 415d99ef7579bf835b7b313d29531164e78dab273f283447d1c46979b2b6f75bb4d38ca82805be8cf2f6fe784c1f90f9a0f39e8e9396f975b3685c80b2e90acd
7
- data.tar.gz: 1917e4170a84a5caa459f410df3d4a605e39363cd53b030112476e60e1bdcb9442bbaeb9862ad8ce58cb6bb49f50c5b7590c6c8abf2e42ef7f966b3665b9ef47
6
+ metadata.gz: 8f52d31a1f5e413efa3155071943b2eaf6a13c49bb3e12b5241969da6f90cec8434a14d32d4de3f693f4ef8c9f5343585e9450e1c9c78d62e12244072e5b0af5
7
+ data.tar.gz: 835fde7f0528eb95ec8bb3faf09844e2b8ae6134796676b40a89a643b103bdb01daa3c7b9e75a742e1b65c7470005d5ad2afab055472cb9cbd1cc14d79e141be
data/README.md CHANGED
@@ -101,6 +101,44 @@ push_to_queue(callback_name, queue_name) if queue_name not passed, callback will
101
101
 
102
102
  Operations work via ActiveJob, so you can use any adapter that you want.
103
103
 
104
+ ### Job
105
+
106
+ I get rid of ActiveJob dependency. So, extend you exting job class with code below
107
+
108
+ ```ruby
109
+ class OpJob < ActiveJob::Base
110
+ queue_as do
111
+ arguments.first[:q_options][:queue]
112
+ end
113
+
114
+ def perform(q_options:, props:)
115
+ "Operationable::Runners::#{q_options[:type].capitalize}".constantize.call(q_options: q_options, props: props)
116
+ end
117
+ end
118
+
119
+ ```
120
+
121
+ Define job class name at your initializers (config/initializers/operationable.rb)
122
+
123
+ ```ruby
124
+ module Operationable
125
+ module Runners
126
+ class Base
127
+ def job_class
128
+ 'OpJob'
129
+ end
130
+
131
+ # This is default behaviour, but you can redefine it, to use with other adapter
132
+ def perform(job_class_name, args)
133
+ job_class_name.to_s.constantize.method(perform_method).call(args)
134
+ end
135
+ end
136
+ end
137
+ end
138
+ ```
139
+
140
+
141
+
104
142
  ### Serializer
105
143
 
106
144
  Serializer used to define what values should be passed to job(redis do not accept AR instances or other complex structures).
@@ -14,8 +14,6 @@ require 'operationable/runners/base'
14
14
  require 'operationable/runners/serial'
15
15
  require 'operationable/runners/separate'
16
16
 
17
- require 'jobs/operation_job'
18
-
19
17
  require 'operations/create'
20
18
  require 'operations/destroy'
21
19
  require 'operations/update'
@@ -8,10 +8,6 @@ module Operationable
8
8
  @q_options = q_options
9
9
  end
10
10
 
11
- def options
12
- @q_options
13
- end
14
-
15
11
  def record
16
12
  @record ||= props[:name].constantize.find(props[:id])
17
13
  end
@@ -116,6 +116,10 @@ module Operationable
116
116
  sync? ? job_sync_execute_method : job_async_execute_method
117
117
  end
118
118
 
119
+ def perform(job_class_name, args)
120
+ job_class_name.to_s.constantize.method(perform_method).call(args)
121
+ end
122
+
119
123
  def sync?
120
124
  %w(test development).include? Rails.env
121
125
  end
@@ -10,10 +10,12 @@ module Operationable
10
10
  # callback can be class
11
11
  # callback_class = callback_method_name.to_s.safe_constantize
12
12
 
13
- (queue.blank? ? self.class : job_class_name.constantize.method(perform_method)).call(
13
+ args = {
14
14
  q_options: q_options(callback_method_name, queue),
15
15
  props: props.merge(params)
16
- )
16
+ }
17
+
18
+ queue.blank? ? self.class.call(args) : perform(job_class_name, args)
17
19
  end
18
20
 
19
21
  def q_options(callback_method_name, queue)
@@ -1,4 +1,5 @@
1
1
  # frozen_string_literal: true
2
+ # TODO: never used, may be remove
2
3
  module Operationable
3
4
  module Runners
4
5
  class Serial < ::Operationable::Runners::Base
@@ -7,7 +8,7 @@ module Operationable
7
8
  end
8
9
 
9
10
  def process
10
- (queue.blank? ? self.class : job_class.to_s.constantize.method(perform_method)).call(
11
+ (queue.blank? ? self.class : perform(job_class_name)).call(
11
12
  q_options: q_options,
12
13
  props: props
13
14
  )
@@ -1,3 +1,3 @@
1
1
  module Operationable
2
- VERSION = "0.5.0"
2
+ VERSION = "0.5.5"
3
3
  end
@@ -22,7 +22,7 @@ Gem::Specification.new do |spec|
22
22
 
23
23
  spec.required_ruby_version = '>= 2.1.0'
24
24
 
25
- spec.add_dependency 'activejob', '>= 4.2.0'
25
+ # spec.add_dependency 'activejob', '>= 4.2.0'
26
26
 
27
27
  spec.add_development_dependency "bundler", "~> 1.13"
28
28
  spec.add_development_dependency "rake", "~> 10.0"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: operationable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0
4
+ version: 0.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kirill Suhodolov
@@ -9,22 +9,8 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2020-12-01 00:00:00.000000000 Z
12
+ date: 2020-12-02 00:00:00.000000000 Z
13
13
  dependencies:
14
- - !ruby/object:Gem::Dependency
15
- name: activejob
16
- requirement: !ruby/object:Gem::Requirement
17
- requirements:
18
- - - ">="
19
- - !ruby/object:Gem::Version
20
- version: 4.2.0
21
- type: :runtime
22
- prerelease: false
23
- version_requirements: !ruby/object:Gem::Requirement
24
- requirements:
25
- - - ">="
26
- - !ruby/object:Gem::Version
27
- version: 4.2.0
28
14
  - !ruby/object:Gem::Dependency
29
15
  name: bundler
30
16
  requirement: !ruby/object:Gem::Requirement
@@ -85,7 +71,6 @@ files:
85
71
  - Rakefile
86
72
  - bin/console
87
73
  - bin/setup
88
- - lib/jobs/operation_job.rb
89
74
  - lib/operationable.rb
90
75
  - lib/operationable/builder.rb
91
76
  - lib/operationable/callback.rb
@@ -1,10 +0,0 @@
1
- # frozen_string_literal: true
2
- class OperationJob < ActiveJob::Base
3
- queue_as do
4
- arguments.first[:q_options][:queue]
5
- end
6
-
7
- def perform(q_options:, props:)
8
- "Operationable::Runners::#{q_options[:type].capitalize}".constantize.call(q_options: q_options, props: props)
9
- end
10
- end