# Singleton method on object via define\_method?

**URL:** <https://rubytalk.org/t/singleton-method-on-object-via-define-method/13537>\
**Category:** ruby-talk\
**Created:** [11 September 2004 09:48 UTC](https://rubytalk.org/t/singleton-method-on-object-via-define-method/13537 "2004-09-11T09:48:07Z")\
**Posts on this page:** 10\
**Page:** 3

<div class="post-metadata">

**Author:** ![Zach\_Dennis1](https://avatars.discourse-cdn.com/v4/letter/z/ea5d25/32.png) [@Zach\_Dennis1](https://rubytalk.org/u/Zach_Dennis1)\
**Post date:** [14 September 2004 01:29 UTC](https://rubytalk.org/t/singleton-method-on-object-via-define-method/13537/41 "2004-09-14T01:29:42Z")

</div>

I've got a dummy site up and working with Arrow, but I have a question....In the httpd.conf file you specify something like:

RubyAddPath /usr/local/lib/ruby/site\_ruby/1.8  
RubyRequire arrow  
\<Location /camphq\>  
&nbsp;&nbsp;&nbsp;SetHandler ruby-object  
&nbsp;&nbsp;&nbsp;RubyHandler "Arrow::Dispatcher::instance( '/var/www/camphq/config/camphq.cfg' )"  
\</Location\>

Where /camphq is how the url of how you want to access your site. IE: [http://mysite.com/camphq](http://mysite.com/camphq) . However in my Arrow config file you have something like:

applets:  
&nbsp;&nbsp;defaultApplet: "/index" #Note this line  
&nbsp;&nbsp;missingApplet: "/missing"  
&nbsp;&nbsp;errorApplet: "/error"  
&nbsp;&nbsp;pattern: "\*.rb"  
&nbsp;&nbsp;path:  
&nbsp;&nbsp;&nbsp;&nbsp;- "/var/www/camphq/applets"  
&nbsp;&nbsp;pollInterval: 5  
&nbsp;&nbsp;config: {}  
&nbsp;&nbsp;layout:  
&nbsp;&nbsp;&nbsp;&nbsp;"/index": Index # Note this line to

You would think that if you went to [http://mysite.com/camphq/index](http://mysite.com/camphq/index) it would run the defaultApplet "/index" (which actually tells the layout "/index" to run ). But it doesn't! Instead you have to say:

applets:  
&nbsp;&nbsp;defaultApplet: "/camphq/index" #Note this line  
&nbsp;&nbsp;missingApplet: "/missing"  
&nbsp;&nbsp;errorApplet: "/error"  
&nbsp;&nbsp;pattern: "\*.rb"  
&nbsp;&nbsp;path:  
&nbsp;&nbsp;&nbsp;&nbsp;- "/var/www/camphq/applets"  
&nbsp;&nbsp;pollInterval: 5  
&nbsp;&nbsp;config: {}  
&nbsp;&nbsp;layout:  
&nbsp;&nbsp;&nbsp;&nbsp;"/camphq/index": Index # Note this line to

in order for the url to work ([http://mysite.com/camphq/index](http://mysite.com/camphq/index) ). Is there a way around this. I would like to assume that the URL root specified in the httpd.conf file was the root of my Arrow-based "Portal" (can i call it that?) Thanks!!

Zach

---

<div class="post-metadata">

**Author:** ![Ptkwt](https://avatars.discourse-cdn.com/v4/letter/p/f14d63/32.png) [@Ptkwt](https://rubytalk.org/u/Ptkwt)\
**Post date:** [14 September 2004 03:40 UTC](https://rubytalk.org/t/singleton-method-on-object-via-define-method/13537/42 "2004-09-14T03:40:18Z")

</div>

In article \<44679.129.94.6.30.1095124491.squirrel@webmail.imagineis.com\>,

> Phil wrote:
> 
> > > module Foo1  
> > > &nbsp;&nbsp;&nbsp;def foo; "foo1"; end  
> > > end
> > > 
> > > module Foo2  
> > > &nbsp;&nbsp;&nbsp;def foo; "foo2"; end  
> > > end
> > > 
> > > class X  
> > > end
> > > 
> > > x = X.new
> > > 
> > > x.foo # error
> > > 
> > > x.extend Foo1  
> > > x.foo # "foo1"
> > > 
> > > x.extend Foo2  
> > > x.foo # "foo2"
> > > 
> > > x.unextend Foo2  
> > > x.foo # "foo1"
> > 
> > Yes, you're right. This would be better behavior. Any idea how  
> > something like that could be implemented?
> 
> Yep: in the Ruby core! 🙂

Yeah, I'm afraid you're probably right (at least to do it 'nicely')

> Only pure-Ruby solution I can think of is to remember the modules that  
> have been mixed in, and selectively reapply earlier ones when 'unextend'  
> is called. Pretty fugly.

Perhaps, but it's probably possible. Is there an 'extended' callback? if not  
'extend' could be redefined.

Phil

> **···**
>
> Gavin Sinclair \<gsinclair@soyabean.com.au\> wrote:

---

<div class="post-metadata">

**Author:** ![Mauricio\_Fernndez](https://avatars.discourse-cdn.com/v4/letter/m/e495f1/32.png) [@Mauricio\_Fernndez](https://rubytalk.org/u/Mauricio_Fernndez)\
**Post date:** [15 September 2004 17:06 UTC](https://rubytalk.org/t/singleton-method-on-object-via-define-method/13537/43 "2004-09-15T17:06:37Z")

</div>

It is I who doesn't understand what the above is supposed to prove 🙂  
Before creating the singleton class of the singleton of o's singleton  
class, to\_s returned "foo", afterwards it returns "#\<Class:foo\>"...  
And anyway, nobody forces us to use to\_s

batsman@tux-chan:/tmp$ cat dfg.rb  
class Class  
&nbsp;&nbsp;# only works for singletons of singletons, will always return  
&nbsp;&nbsp;# true otherwise  
&nbsp;&nbsp;&nbsp;&nbsp;def has\_singleton?  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m = "\_\_magic\_#{Time.new.to\_i}\_#{rand(100000)}"  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;class\_eval do  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;remove\_method(m) rescue nil  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;define\_method(m) { }  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;send m  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rescue NameError  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return true  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ensure  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;remove\_method m  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end  
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;false  
&nbsp;&nbsp;&nbsp;&nbsp;end  
end

o = Object.new  
klass = class \<\< o; class \<\< self; self end end  
p klass.has\_singleton?  
class \<\< klass; end  
p klass.has\_singleton?

batsman@tux-chan:/tmp$ ruby dfg.rb  
false  
true

> **···**
>
> On Wed, Sep 15, 2004 at 09:49:50PM +0900, Robert Klemme wrote:
> 
> > \> \> \>\> o = Object.new  
> > \> \> =\> #\<Object:0x10184d40\>  
> > \> \> \>\> class \<\< o; class \<\< self; def to\_s ; "foo" end end end  
> > \> \> =\> nil  
> > \> \> \>\> class \<\< o; class \<\< self;to\_s end end  
> > \> \> =\> "foo"  
> > \> \> \>\> class \<\< o; class \<\< self; class \<\< self; end end end  
> > \> \> =\> nil  
> > \> \> \>\> class \<\< o; class \<\< self; to\_s end end  
> > \> \> =\> "#\<Class:foo\>"  
> > \>  
> > \> It's using Module#to\_s because the klass of the singleton class is  
> > \> no longer itself... Module#to\_s ends up calling  
> > \> class \<\< o; self.to\_s end  
> > \> which you defined before.
> > 
> > Well yes, but the fact remains that there is a singleton we don't know of,  
> > do we? Probably I don't see clearly your point so I'd appreciate it if  
> > you'd elaborate it.
> 
> --  
> Running Debian GNU/Linux Sid (unstable)  
> batsman dot geo at yahoo dot com

---

<div class="post-metadata">

**Author:** ![Gavin\_Sinclair](https://avatars.discourse-cdn.com/v4/letter/g/db5fbb/32.png) [@Gavin\_Sinclair](https://rubytalk.org/u/Gavin_Sinclair)\
**Post date:** [14 September 2004 03:48 UTC](https://rubytalk.org/t/singleton-method-on-object-via-define-method/13537/44 "2004-09-14T03:48:15Z")

</div>

Phil wrote:

> > Only pure-Ruby solution I can think of is to remember the modules that  
> > have been mixed in, and selectively reapply earlier ones when  
> > 'unextend' is called. Pretty fugly.
> 
> Perhaps, but it's probably possible. Is there an 'extended' callback?  
> if not 'extend' could be redefined.

The callback you're after is Module#append\_features, from memory. On  
first thought, I doubt that's useful, because it's from each individual  
module's POV.

If I were implementing this, I'd create new methods rather than modify  
#entend, at least at first. Something like:

&nbsp;&nbsp;Object#wrap(module)  
&nbsp;&nbsp;Object#unwrap(module)

Perhaps a traits lit. review would turn up some agreeable terminology.

Cheers,  
Gavin

---

<div class="post-metadata">

**Author:** ![Robert](https://avatars.discourse-cdn.com/v4/letter/r/e95f7d/32.png) [@Robert](https://rubytalk.org/u/Robert)\
**Post date:** [15 September 2004 22:39 UTC](https://rubytalk.org/t/singleton-method-on-object-via-define-method/13537/45 "2004-09-15T22:39:49Z")

</div>

"Mauricio Fernández" \<batsman.geo@yahoo.com\> schrieb im Newsbeitrag news:20040915170634.GA25725@student.ei.uni-stuttgart.de...

> > \> \> \>\> o = Object.new  
> > \> \> =\> #\<Object:0x10184d40\>  
> > \> \> \>\> class \<\< o; class \<\< self; def to\_s ; "foo" end end end  
> > \> \> =\> nil  
> > \> \> \>\> class \<\< o; class \<\< self;to\_s end end  
> > \> \> =\> "foo"  
> > \> \> \>\> class \<\< o; class \<\< self; class \<\< self; end end end  
> > \> \> =\> nil  
> > \> \> \>\> class \<\< o; class \<\< self; to\_s end end  
> > \> \> =\> "#\<Class:foo\>"  
> > \>  
> > \> It's using Module#to\_s because the klass of the singleton class is  
> > \> no longer itself... Module#to\_s ends up calling  
> > \> class \<\< o; self.to\_s end  
> > \> which you defined before.
> > 
> > Well yes, but the fact remains that there is a singleton we don't know of,  
> > do we? Probably I don't see clearly your point so I'd appreciate it if  
> > you'd elaborate it.
> 
> It is I who doesn't understand what the above is supposed to prove 🙂

Utter confusion on all sides. :-)))

My understanding: someone (I?) made a remark about the fact (well, assumed fact) that you can't test whether an instance has a singleton class. You can access it, but you will not know whether it was created for this access or whether it existed before. You then presented the example with a NameError due to undefined method foo. I thought, you use the NameError for detecting the singleton class, hence I used to\_s which I know is always defined and thus would not trigger the exception. The idea being to disprove the test. Maybe I got something wrong here...

> Before creating the singleton class of the singleton of o's singleton  
> class, to\_s returned "foo", afterwards it returns "#\<Class:foo\>"...  
> And anyway, nobody forces us to use to\_s
> 
> batsman@tux-chan:/tmp$ cat dfg.rb  
> class Class  
> # only works for singletons of singletons, will always return  
> # true otherwise  
> &nbsp;&nbsp;&nbsp;def has\_singleton?  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;m = "\_\_magic\_#{Time.new.to\_i}\_#{rand(100000)}"  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;class\_eval do  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;remove\_method(m) rescue nil  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;define\_method(m) { }  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;begin  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;send m  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;rescue NameError  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return true  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;ensure  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;remove\_method m  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;end  
> &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;false  
> &nbsp;&nbsp;&nbsp;end  
> end

I'm not sure whether I fully understand what the test should do. But it's late and I'll better go to bed now. A brain with some sleep thinks better...

> o = Object.new  
> klass = class \<\< o; class \<\< self; self end end  
> p klass.has\_singleton?  
> class \<\< klass; end  
> p klass.has\_singleton?
> 
> batsman@tux-chan:/tmp$ ruby dfg.rb  
> false  
> true

Hm, but what does this tell me:

> > o = Object.new

=\> #\<Object:0x10194858\>

> > klass = class \<\< o; self end

=\> #\<Class:#\<Object:0x10194858\>\>

> > klass.has\_singleton?

=\> true

The answer is definitely wrong, because the singleton class of o does not have a singleton klass. Hm...

For the moment I'll stick with my statement that it's generally not possible to determine whether an instance has a singleton or not other than by using some kind of extension. 🙂

Kind regards

&nbsp;&nbsp;&nbsp;&nbsp;robert

> **···**
>
> > On Wed, Sep 15, 2004 at 09:49:50PM +0900, Robert Klemme wrote:

---

<div class="post-metadata">

**Author:** ![Michael\_Granger](https://avatars.discourse-cdn.com/v4/letter/m/a88e4f/32.png) [@Michael\_Granger](https://rubytalk.org/u/Michael_Granger)\
**Post date:** [16 September 2004 06:11 UTC](https://rubytalk.org/t/singleton-method-on-object-via-define-method/13537/46 "2004-09-16T06:11:07Z")

</div>

> I've got a dummy site up and working with Arrow, but I have a question....In the httpd.conf file you specify something like:  
> [...]  
> You would think that if you went to [http://mysite.com/camphq/index](http://mysite.com/camphq/index) it would run the defaultApplet "/index" (which actually tells the layout "/index" to run ). But it doesn't! Instead you have to say:

Yes, this is how it's supposed to work.

> applets:  
> defaultApplet: "/camphq/index" #Note this line  
> missingApplet: "/missing"  
> errorApplet: "/error"  
> pattern: "\*.rb"  
> path:  
> &nbsp;&nbsp;&nbsp;- "/var/www/camphq/applets"  
> pollInterval: 5  
> config: {}  
> layout:  
> &nbsp;&nbsp;&nbsp;"/camphq/index": Index # Note this line to
> 
> in order for the url to work ([http://mysite.com/camphq/index](http://mysite.com/camphq/index) ). Is there a way around this. I would like to assume that the URL root specified in the httpd.conf file was the root of my Arrow-based "Portal" (can i call it that?) Thanks!!

I'm at a loss to explain what's going on, as I can't reproduce this. When I map something in the layout as '/camphq/index', I have to go to /camphq/camphq/index to get it to run. Would you mind bumping your LogLevel in httpd.conf and logLevel in your camphq.conf up to 'debug' and mailing me the output in your error log for one request to /camphq/index?

[PGP.sig](https://rubytalk.org/uploads/short-url/2Cqxu3VUmijfk3xKoHckBS6Q6hd.sig) (186 Bytes)

> **···**
>
> On Sep 13, 2004, at 6:29 PM, Zach Dennis wrote:  
> --  
> Michael Granger \<ged@FaerieMUD.org\>  
> Rubymage, Believer, Architect  
> The FaerieMUD Consortium \<[http://www.FaerieMUD.org/&gt](http://www.FaerieMUD.org/&gt);  
> 12383406064495388618631689469409153107.to\_s(36).tr('z',' ')

---

<div class="post-metadata">

**Author:** ![Mauricio\_Fernndez](https://avatars.discourse-cdn.com/v4/letter/m/e495f1/32.png) [@Mauricio\_Fernndez](https://rubytalk.org/u/Mauricio_Fernndez)\
**Post date:** [15 September 2004 23:31 UTC](https://rubytalk.org/t/singleton-method-on-object-via-define-method/13537/47 "2004-09-15T23:31:47Z")

</div>

> \>\>Well yes, but the fact remains that there is a singleton we don't know  
> \>\>of,  
> \>\>do we? Probably I don't see clearly your point so I'd appreciate it if  
> \>\>you'd elaborate it.  
> \>  
> \>It is I who doesn't understand what the above is supposed to prove 🙂
> 
> Utter confusion on all sides. :-)))
> 
> My understanding: someone (I?) made a remark about the fact (well, assumed  
> fact) that you can't test whether an instance has a singleton class. You  
> can access it, but you will not know whether it was created for this access  
> or whether it existed before. You then presented the example with a  
> NameError due to undefined method foo.

It's more than a NameError, it's an anomaly in Ruby's object model that  
I can detect as a \*successful\* call that should fail. You get the  
NameError when that anomalous situation is no longer there (pushed one  
singleton away, so to speak).

> I thought, you use the NameError  
> for detecting the singleton class, hence I used to\_s which I know is always

But I wouldn't use #to\_s for the test \*g\*

> defined and thus would not trigger the exception. The idea being to  
> disprove the test. Maybe I got something wrong here...

That could be detected and a new (random) name would be used.

> \>batsman@tux-chan:/tmp$ cat dfg.rb  
> \>class Class  
> \># only works for singletons of singletons, will always return  
> \># true otherwise  
> \> def has\_singleton?  
> \> m = "\_\_magic\_#{Time.new.to\_i}\_#{rand(100000)}"  
> \> class\_eval do  
> \> remove\_method(m) rescue nil  
> \> define\_method(m) { }  
> \> begin  
> \> send m  
> \> rescue NameError  
> \> return true  
> \> ensure  
> \> remove\_method m  
> \> end  
> \> end  
> \> false  
> \> end  
> \>end
> 
> I'm not sure whether I fully understand what the test should do. But it's  
> late and I'll better go to bed now. A brain with some sleep thinks  
> better...
> 
> \>o = Object.new  
> \>klass = class \<\< o; class \<\< self; self end end  
> \>p klass.has\_singleton?  
> \>class \<\< klass; end  
> \>p klass.has\_singleton?  
> \>  
> \>batsman@tux-chan:/tmp$ ruby dfg.rb  
> \>false  
> \>true
> 
> Hm, but what does this tell me:
> 
> \>\>o = Object.new  
> =\> #\<Object:0x10194858\>  
> \>\>klass = class \<\< o; self end  
> =\> #\<Class:#\<Object:0x10194858\>\>  
> \>\>klass.has\_singleton?  
> =\> true
> 
> The answer is definitely wrong, because the singleton class of o does not  
> have a singleton klass. Hm...

Hence the warning in my code:  
&nbsp;&nbsp;# only works for singletons of singletons, will always return  
&nbsp;&nbsp;# true otherwise  
that is, it only says the truth when called on singletons of singletons.  
In the snippet above, you called it on a singleton of a non-singleton.

> For the moment I'll stick with my statement that it's generally not  
> possible to determine whether an instance has a singleton or not other than  
> by using some kind of extension. 🙂

We're both right, it is generally impossible, and "there's at least one  
case where you can know if the singleton class has been created or not  
(singletons of singletons)".

(And you can always know if you're using evil.rb, of course 🙂

> **···**
>
> On Thu, Sep 16, 2004 at 07:39:49AM +0900, Robert Klemme wrote:
> 
> --  
> Running Debian GNU/Linux Sid (unstable)  
> batsman dot geo at yahoo dot com

---

<div class="post-metadata">

**Author:** ![Zach\_Dennis1](https://avatars.discourse-cdn.com/v4/letter/z/ea5d25/32.png) [@Zach\_Dennis1](https://rubytalk.org/u/Zach_Dennis1)\
**Post date:** [19 September 2004 20:22 UTC](https://rubytalk.org/t/singleton-method-on-object-via-define-method/13537/48 "2004-09-19T20:22:45Z")

</div>

Michael Granger wrote:

> > I've got a dummy site up and working with Arrow, but I have a question....In the httpd.conf file you specify something like:  
> > [...]  
> > You would think that if you went to [http://mysite.com/camphq/index](http://mysite.com/camphq/index) it would run the defaultApplet "/index" (which actually tells the layout "/index" to run ). But it doesn't! Instead you have to say:
> 
> Yes, this is how it's supposed to work.
> 
> > applets:  
> > defaultApplet: "/camphq/index" #Note this line  
> > missingApplet: "/missing"  
> > errorApplet: "/error"  
> > pattern: "\*.rb"  
> > path:  
> > &nbsp;&nbsp;&nbsp;- "/var/www/camphq/applets"  
> > pollInterval: 5  
> > config: {}  
> > layout:  
> > &nbsp;&nbsp;&nbsp;"/camphq/index": Index # Note this line to
> > 
> > in order for the url to work ([http://mysite.com/camphq/index](http://mysite.com/camphq/index) ). Is there a way around this. I would like to assume that the URL root specified in the httpd.conf file was the root of my Arrow-based "Portal" (can i call it that?) Thanks!!
> 
> I'm at a loss to explain what's going on, as I can't reproduce this. When I map something in the layout as '/camphq/index', I have to go to /camphq/camphq/index to get it to run. Would you mind bumping your LogLevel in httpd.conf and logLevel in your camphq.conf up to 'debug' and mailing me the output in your error log for one request to /camphq/index?

Here is my error.log output:

[Sun Sep 19 16:23:54 2004] [error] [client 10.0.1.61] File does not exist: /var/www/camphq.com/favicon.ico  
[Sun Sep 19 16:23:58 2004] [notice] (global) : Arrow config file is "/var/www/camphq/config/camphq.cfg"  
[Sun Sep 19 16:23:58 2004] [notice] Arrow::Dispatcher : Configuring a dispatcher for 'camphq.com': child server 13833  
[Sun Sep 19 16:23:58 2004] [notice] Arrow::Dispatcher : Monitor skipped by configuration  
[Sun Sep 19 16:23:58 2004] [notice] Arrow::Dispatcher : Setting global log level to :debug  
[Sun Sep 19 16:23:58 2004] [notice] Arrow::Dispatcher : Configuring the Session class with #\<Arrow::Config:0x40721e24 @loader=#\<Arrow::Config::YamlLoader:0x40729bb0\>, @name="/var/www/camphq/config/camphq.cfg", @createTime=Sun Sep 19 16:23:58 UTC 2004, @struct=#\<Arrow::Config::ConfigStruct:0x4071fae8 @modified=false, @hash={:templates=\>{:loader=\>"Arrow::Template", :path=\>["/var/www/camphq/templates"], :cacheConfig=\>{:maxSize=\>2621440, :expiration=\>36, :maxNum=\>20, :maxObjSize=\>131072}, :cache=\>false}, :startMonitor=\>false, :session=\>{:storeType=\>"file:/tmp", :expires=\>"+48h", :idName=\>"arrow-session", :rewriteUrls=\>true, :idType=\>"md5:.", :lockType=\>"recommended"}, :applets=\>{:missingApplet=\>"/missing", :path=\>["/var/www/camphq/applets"], :pollInterval=\>5, :pattern=\>"\*.rb", :errorApplet=\>"/error", :defaultApplet=\>"/index", :config=\>{}, :layout=\>{:"/index"=\>"Index", :"/camphq/protected/index"=\>"Index", :"/camphq/protected"=\>"ProtectedDelegator"}}, :logLevel=\>"debug", :unittester=\>{:dbenv=\>"/www/data/applettests"}, :templateLogLevel=\>"debug"}\>\>  
[Sun Sep 19 16:23:58 2004] [notice] Arrow::Dispatcher : Creating request broker  
[Sun Sep 19 16:23:58 2004] [error] Arrow::Broker : Configured MissingApplet handler (/missing) doesn't exist  
[Sun Sep 19 16:23:58 2004] [notice] Arrow::Broker : Using builtin missing-applet handler.  
[Sun Sep 19 16:23:58 2004] [error] Arrow::Broker : Applet returned false value. Setting status to DECLINED  
[Sun Sep 19 16:23:58 2004] [notice] Arrow::Dispatcher : Transaction has non-OK status: -1  
[Sun Sep 19 16:23:58 2004] [error] [client 10.0.1.61] File does not exist: /var/www/camphq.com/camphq/index  
[Sun Sep 19 16:23:58 2004] [error] [client 10.0.1.61] File does not exist: /var/www/camphq.com/favicon.ico

Thanks,

Zach

> **···**
>
> > On Sep 13, 2004, at 6:29 PM, Zach Dennis wrote:

---

<div class="post-metadata">

**Author:** ![Robert](https://avatars.discourse-cdn.com/v4/letter/r/e95f7d/32.png) [@Robert](https://rubytalk.org/u/Robert)\
**Post date:** [16 September 2004 07:29 UTC](https://rubytalk.org/t/singleton-method-on-object-via-define-method/13537/49 "2004-09-16T07:29:48Z")

</div>

"Mauricio Fernández" \<batsman.geo@yahoo.com\> schrieb im Newsbeitrag  
news:20040915233138.GA2327@student.ei.uni-stuttgart.de...

\<snip/\>

Thanks for the wrap up!

> We're both right, it is generally impossible, and "there's at least one  
> case where you can know if the singleton class has been created or not  
> (singletons of singletons)".

What a nice solution. :-))

> (And you can always know if you're using evil.rb, of course 🙂

Yah, but that's evil. 🙂

&nbsp;&nbsp;&nbsp;&nbsp;robert

---

<div class="post-metadata">

**Author:** ![Zach\_Dennis1](https://avatars.discourse-cdn.com/v4/letter/z/ea5d25/32.png) [@Zach\_Dennis1](https://rubytalk.org/u/Zach_Dennis1)\
**Post date:** [19 September 2004 21:24 UTC](https://rubytalk.org/t/singleton-method-on-object-via-define-method/13537/50 "2004-09-19T21:24:19Z")

</div>

Michael,

I found my problem. My Apache httpd.conf file was pointing to "/var/www/camphq.com" as the directory root. That directory did not exist. but "/var/www/camphq" did.

When I supplied a full URL: "[http://www.camphq.com/index](http://www.camphq.com/index)" it couldn't find index because it was looking for index in the /var/www/camphq.com/applets directory. When I supplied the "camphq" post-fix on the URL then Arrow was able to correctly handle it because I told it to specifically go to /camphq.

I made a symlink from /var/www/camphq.com to /var/www/camphq and switched my configuration file for Arrow, and it is working like a charm.

Sorry for the confusion.

Zach

[Previous page](https://rubytalk.org/t/singleton-method-on-object-via-define-method/13537.md?page=2)
