Module: Bj::Mixin::Async
- Defined in:
- lib/bj/mixin/async.rb
Overview
Module that provides easy queueing of jobs. Transparently handles instance and class methods.
If you consider this class:
class Repository < ActiveRecord::Base
include Bj::Mixin::Async
def self.create_index
# code
end
def notify_watchers
# code
end
end
you can queue new jobs on both the class and an instance like this:
@repository.async(:notify_watchers)
Repository.async(:create_index)
Defined Under Namespace
Modules: ClassMethods
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(base) ⇒ Object
26 27 28 |
# File 'lib/bj/mixin/async.rb', line 26 def self.included(base) base.extend(ClassMethods) end |
Instance Method Details
#async(method, *args) ⇒ Object
30 31 32 |
# File 'lib/bj/mixin/async.rb', line 30 def async(method, *args) Bj.submit "CACHE_CLASSES=true ./script/runner '#{self.class.name}.perform(#{id}, #{method.inspect})'", :stdin => args.to_yaml, :is_restartable => false end |