acts_as_async 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/LICENSE +20 -0
- data/README.md +3 -0
- data/lib/acts_as_async/base_extensions.rb +21 -0
- data/lib/acts_as_async/helper.rb +50 -0
- data/lib/acts_as_async/railtie.rb +10 -0
- data/lib/acts_as_async/version.rb +3 -0
- data/lib/acts_as_async.rb +8 -0
- metadata +89 -0
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) Brendan Loudermilk
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
module ActsAsAsync
|
2
|
+
module BaseExtensions
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
module ClassMethods
|
6
|
+
def acts_as_async(opts={})
|
7
|
+
# Make the default queue for this class "default"
|
8
|
+
opts.reverse_merge!(queue: :default)
|
9
|
+
|
10
|
+
# Set the queue unless one is already set
|
11
|
+
unless instance_variable_defined?(:@queue)
|
12
|
+
instance_variable_set(:@queue, opts[:queue])
|
13
|
+
end
|
14
|
+
|
15
|
+
include ActsAsAsync::Helper
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
ActiveRecord::Base.send :include, ActsAsAsync::BaseExtensions
|
@@ -0,0 +1,50 @@
|
|
1
|
+
module ActsAsAsync
|
2
|
+
module Helper
|
3
|
+
extend ActiveSupport::Concern
|
4
|
+
|
5
|
+
module ClassMethods
|
6
|
+
# Args will be an optional ID, a method name and optional arguments
|
7
|
+
def perform(*args)
|
8
|
+
# Class methods
|
9
|
+
if args.first.is_a? String
|
10
|
+
receiver = self
|
11
|
+
method = args.shift
|
12
|
+
|
13
|
+
# Instance methods
|
14
|
+
else
|
15
|
+
id = args.shift
|
16
|
+
receiver = find(id)
|
17
|
+
method = args.shift
|
18
|
+
end
|
19
|
+
|
20
|
+
receiver.send(method, *args)
|
21
|
+
end
|
22
|
+
|
23
|
+
def async(method, *args)
|
24
|
+
Resque.enqueue(self, method, *args)
|
25
|
+
end
|
26
|
+
|
27
|
+
def async_at(time, method, *args)
|
28
|
+
Resque.enqueue_at(time, self, method, *args)
|
29
|
+
end
|
30
|
+
|
31
|
+
def async_in(time, method, *args)
|
32
|
+
Resque.enqueue_in(time, self, method, *args)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
module InstanceMethods
|
37
|
+
def async(method, *args)
|
38
|
+
Resque.enqueue(self.class, id, method, *args)
|
39
|
+
end
|
40
|
+
|
41
|
+
def async_at(time, method, *args)
|
42
|
+
Resque.enqueue_at(time, self.class, id, method, *args)
|
43
|
+
end
|
44
|
+
|
45
|
+
def async_in(time, method, *args)
|
46
|
+
Resque.enqueue_in(time, self.class, id, method, *args)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
metadata
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: acts_as_async
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Brendan Loudermilk
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-10-21 00:00:00.000000000Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: resque
|
16
|
+
requirement: &70318317253520 !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: *70318317253520
|
25
|
+
- !ruby/object:Gem::Dependency
|
26
|
+
name: resque-scheduler
|
27
|
+
requirement: &70318317253100 !ruby/object:Gem::Requirement
|
28
|
+
none: false
|
29
|
+
requirements:
|
30
|
+
- - ! '>='
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '0'
|
33
|
+
type: :runtime
|
34
|
+
prerelease: false
|
35
|
+
version_requirements: *70318317253100
|
36
|
+
- !ruby/object:Gem::Dependency
|
37
|
+
name: activerecord
|
38
|
+
requirement: &70318317252680 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ! '>='
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
version: '0'
|
44
|
+
type: :runtime
|
45
|
+
prerelease: false
|
46
|
+
version_requirements: *70318317252680
|
47
|
+
description: ! ' This gem is so crazy you won''t believe.
|
48
|
+
|
49
|
+
'
|
50
|
+
email: brendan@gophilosophie.com
|
51
|
+
executables: []
|
52
|
+
extensions: []
|
53
|
+
extra_rdoc_files:
|
54
|
+
- LICENSE
|
55
|
+
- README.md
|
56
|
+
files:
|
57
|
+
- README.md
|
58
|
+
- LICENSE
|
59
|
+
- lib/acts_as_async/base_extensions.rb
|
60
|
+
- lib/acts_as_async/helper.rb
|
61
|
+
- lib/acts_as_async/railtie.rb
|
62
|
+
- lib/acts_as_async/version.rb
|
63
|
+
- lib/acts_as_async.rb
|
64
|
+
homepage: http://github.com/bloudermilk/acts_as_async
|
65
|
+
licenses: []
|
66
|
+
post_install_message:
|
67
|
+
rdoc_options:
|
68
|
+
- --charset=UTF-8
|
69
|
+
require_paths:
|
70
|
+
- lib
|
71
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
72
|
+
none: false
|
73
|
+
requirements:
|
74
|
+
- - ! '>='
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '0'
|
77
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
78
|
+
none: false
|
79
|
+
requirements:
|
80
|
+
- - ! '>='
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: '0'
|
83
|
+
requirements: []
|
84
|
+
rubyforge_project:
|
85
|
+
rubygems_version: 1.8.10
|
86
|
+
signing_key:
|
87
|
+
specification_version: 3
|
88
|
+
summary: Acts As Async is a Resque-backed ActiveRecord delayed job tool
|
89
|
+
test_files: []
|