[Backgroundrb-devel] Instantiating middleman and worker from inside a model?

Joshua Bates joshuabates at gmail.com
Mon Jan 15 13:51:58 EST 2007


Just call work_thread on the worker.
Something like....

def save_to_s3
  worker.work_thread(:method => :save, :args => [args])
end

def worker
  @worker ||= MiddleMan.worker(:s3)
end

If you need to pass the whole model to the worker, make sure to add
include DRbUndumped in your model.

On 1/15/07, Tomasz Kaye <tomasz at resourcestudio.nl> wrote:
>
> In short: how (if possible) would i go about arranging it so that i
> can instantiate a middleman and set a worker going from within a
> method in one of my models? or is this a weird thing to be wanting to
> do? (
>
> My specific situation: I have an 'Image' model in my application. An
> actual image file associated with the model is being stored on
> amazons s3 system. I'd like to use a worker to handle each s3
> operation (eg. deleting the image from s3). The Image model seems the
> neatest place to set the worker going but I'm a little stumped as to
> how i should modify my model to enable the instantiation of middleman
> within it.
>
> thanks in advance for any pointers!
>
> (apologies in advance if this message gets posted twice; i think my
> previous attempt didn't work)
> _______________________________________________
> Backgroundrb-devel mailing list
> Backgroundrb-devel at rubyforge.org
> http://rubyforge.org/mailman/listinfo/backgroundrb-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20070115/8c04f408/attachment.html 


More information about the Backgroundrb-devel mailing list