Re: RubyInitHandler Problems

"Hammond, Tony" <[email protected]> Thu, 29 Jul 2004 11:20:13 +0100
Newsgroups gmane.comp.apache.mod-ruby
Message-ID <[email protected]>
Hi Shugo:

Thanks - that worked. But perhaps wasn't what I wanted. What I did want was
to persist a data structure (read in from an external file) across multiple
calls to a .rbx script. What would be the best way of doing that? (Seems
that RubyInitHandler is called at _each_ invocation of a .rbx script.)

Thanks,

Tony


> -----Original Message-----
> From: Shugo Maeda [mailto:[email protected]] 
> Sent: 28 July 2004 18:15
> To: [email protected]
> Subject: Re: RubyInitHandler Problems
> 
> 
> Hi,
> 
> Hammond, Tony wrote:
> > ===
> > RubyRequire apache/ruby-run
> > RubyRequire foo/bar
> > 
> > <Files *.rbx>
> >   SetHandler ruby-object
> >   RubyInitHandler Foo::Bar.load_data
> >   RubyHandler Apache::RubyRun.instance
> > </Files>
> 
> The parameter of RubyInitHandler should be an expression that 
> returns an init handler object. Init handler objects should 
> have `init' method.
> 
> --- example of init handler ---
> require 'singleton'
> 
> class MyInitHandler
>   include Singleton
> 
>   def init(r)
>     ...
>   end
> end
> --------------------------------
> 
> You can register this handler like this:
> 
>   RubyHandler MyInitHandler.instance
> 
> `instance' is defined in Singleton, and always returns a same 
> instance of MyInitHandler.
> 
> Shugo
> 



********************************************************************************
DISCLAIMER: This e-mail is confidential and should not be used by anyone who is not the original intended recipient. If you have received this e-mail in error please inform the sender and delete it from your mailbox or any other storage mechanism. Neither Macmillan Publishers Limited nor any of its agents accept liability for any statements made which are clearly the sender's own and not expressly made on behalf of Macmillan Publishers Limited or one of its agents. Please note that neither Macmillan Publishers Limited nor any of its agents accept any responsibility for viruses that may be contained in this e-mail or its attachments and it is your responsibility to scan the e-mail and attachments (if any). No contracts may be concluded on behalf of Macmillan Publishers Limited or its agents by means of e-mail communication. Macmillan Publishers Limited Registered in England and Wales with
  registered number 785998 Registered Office Brunel Road, Houndmills, Basingstoke RG21 6XS
********************************************************************************