Module: Bj::Mixin::Async::ClassMethods
- Defined in:
- lib/bj/mixin/async.rb
Instance Method Summary collapse
- #async(method, *args) ⇒ Object
-
#perform(id, method) ⇒ Object
Performs a class method if id is nil or an instance method if id has a value.
Instance Method Details
#async(method, *args) ⇒ Object
35 36 37 |
# File 'lib/bj/mixin/async.rb', line 35 def async(method, *args) Bj.submit "CACHE_CLASSES=true ./script/runner '#{self.name}.perform(nil, #{method.inspect})'", :stdin => args.to_yaml, :is_restartable => false end |
#perform(id, method) ⇒ Object
Performs a class method if id is nil or an instance method if id has a value.
41 42 43 44 45 46 |
# File 'lib/bj/mixin/async.rb', line 41 def perform(id, method) args = YAML.load(STDIN) obj = id ? find(id) : self obj.send(method, *args) end |