message 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +1 -1
- data/lib/message/worker.rb +3 -3
- metadata +1 -1
data/README.md
CHANGED
@@ -36,7 +36,7 @@ Inspired by delayed_job API, call .async.method(params) on any object and it wil
|
|
36
36
|
|
37
37
|
### Change to synchronize mode
|
38
38
|
|
39
|
-
Message.worker.
|
39
|
+
Message.worker.sync = true
|
40
40
|
|
41
41
|
This is designed for test environment or Rails development environment.
|
42
42
|
After set the synch option to true, the async jobs will be processed immediately when .async.method(params) is called.
|
data/lib/message/worker.rb
CHANGED
@@ -28,7 +28,7 @@ module Message
|
|
28
28
|
end
|
29
29
|
|
30
30
|
class << self
|
31
|
-
attr_accessor :default_job, :
|
31
|
+
attr_accessor :default_job, :sync
|
32
32
|
|
33
33
|
def default_job
|
34
34
|
@default_job ||= DEFAULT_JOB_NAME
|
@@ -52,7 +52,7 @@ module Message
|
|
52
52
|
|
53
53
|
def reset
|
54
54
|
@default_job = nil
|
55
|
-
@
|
55
|
+
@sync = nil
|
56
56
|
@jobs = nil
|
57
57
|
end
|
58
58
|
end
|
@@ -84,7 +84,7 @@ module Message
|
|
84
84
|
|
85
85
|
def enq(work)
|
86
86
|
job.enq(YAML.dump(work)).tap do
|
87
|
-
process if self.class.
|
87
|
+
process if self.class.sync
|
88
88
|
end
|
89
89
|
end
|
90
90
|
alias :<< :enq
|