momentarily 0.0.4 → 0.0.6
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.textile +4 -2
- data/lib/momentarily.rb +2 -1
- data/lib/momentarily/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4eea39d03678c3767a0aa7fc8ad41a26cdf2480c
|
4
|
+
data.tar.gz: 5127c379c8bb101d7d4eccaafa49ec3840234535
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 31eab64be3b5cf889acdb8a8410e831881d8a607fc0879d8427af4d9a48a36d8c3a46e1b5a1dbd12969f3ec2bd5f92e4866d2945709637d5fcf1420698ba07f9
|
7
|
+
data.tar.gz: c65f4d1c8487c714ac2a52cba6ff9065d3a1f84bcd4779dabde787a541d76f6abf0eb498d3653257cebc94b85af64804a41d7a41a24de3a51e882f9f448ad3bb
|
data/README.textile
CHANGED
@@ -16,12 +16,14 @@ You'll then need to start the reactor. Create a *config/initializers/momentarily
|
|
16
16
|
|
17
17
|
<pre><code>
|
18
18
|
Momentarily.start
|
19
|
+
|
20
|
+
# if classes aren't cached they will disappear from thread
|
21
|
+
# or we are testing for conditions, just run the code immediately
|
22
|
+
Momentarily.inline = true if Rails.env.development? || Rails.env.test?
|
19
23
|
</code></pre>
|
20
24
|
|
21
25
|
That's it! Once complete, *Momentarily.reactor_running?* should be true.
|
22
26
|
|
23
|
-
Note that momentarily will not defer tasks if Rails.env.test? is true.
|
24
|
-
|
25
27
|
Momentarily provides the very useful "later" command. Calling .later will spawn a thread to complete the tasks you provide, allowing your Rails requests to complete and return to users. For example:
|
26
28
|
|
27
29
|
<pre><code>
|
data/lib/momentarily.rb
CHANGED
@@ -14,6 +14,7 @@ module Momentarily
|
|
14
14
|
mattr_accessor :timeout, :debug
|
15
15
|
@@timeout = 60
|
16
16
|
@@debug = false
|
17
|
+
@@inline = false
|
17
18
|
|
18
19
|
def Momentarily.start
|
19
20
|
# faciliates debugging
|
@@ -50,7 +51,7 @@ module Momentarily
|
|
50
51
|
end
|
51
52
|
|
52
53
|
def Momentarily.later(work = nil, callback = nil, &block)
|
53
|
-
if
|
54
|
+
if @@inline
|
54
55
|
(work || block).call
|
55
56
|
callback.call unless callback.blank?
|
56
57
|
else
|
data/lib/momentarily/version.rb
CHANGED