Module: MicroQ::Methods::ActiveRecord
- Defined in:
- lib/micro_q/methods/active_record.rb
Overview
Methods that are added to AR instances
When processing instance methods asynchronously, AR objects should not be stored. Instances that are backed by a database are herby serialized and re-queried from the DB at runtime. For AR that means simply storing the class and adding a custom ‘loader’
A Loader is an additional step before a method is invoked that generates a target object from a method invocation and arguments. In the case of AR, what better then ‘find’. Here we simply store the id as the argument for find.
Instance Method Summary collapse
Instance Method Details
#async(options = {}) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/micro_q/methods/active_record.rb', line 17 def async( = {}) defaults = { :class => self.class, :loader => { :method => 'find', :args => [id] } } MicroQ::Proxy::Instance.new( .merge(defaults) ) end |