Ask a Question related to Ruby, Design and Development.
-
Ian Macdonald #1
anonymous classes
Hi,
Could someone please explain to me the concept of an anonymous class?
I'm talking about this construct:
class << Foo
...
end
I'm having a hard time understanding the books and figuring out when I
might actually want/need to use this.
Ian
--
Ian Macdonald | Keep cool, but don't freeze. -- Hellman's
System Administrator | Mayonnaise
[email]ian@caliban.org[/email] |
[url]http://www.caliban.org[/url] |
|
Ian Macdonald Guest
-
IIS 6.0 with anonymous access and on MX 6.1
I was having a hard time setting up IIS 6.0 with anonymous access on MX6.1 I was able to run .asp extension but when running .cfm, I got the HTTP... -
IIS Not using anonymous impersonation
Hi, I havea web app that has anonymous accesss enabled. I have specified that IIS should have the credentials of a user in the active directory.... -
ASP.NET Anonymous Impersonation
Hi, When you impersonate with anonymous security what is suppose to happen (IIS5 platform). Is it the aspnet_wp.exe process runs under the... -
anonymous logon
I have aproblem. I develop my asp.net site at my pc (named PCMANOS)(running IIS) and I have the SQL Server at another pc (named ATHDC). I've... -
How do I log onto anonymous ftp ?
Hello I have logged onto ftps before, but never an anonymous one. I need to log into ftp://archive.progeny.com/ I can view the files with... -
Chad Fowler #2
Re: anonymous classes
Ian Macdonald wrote:
This may be a good starting point:>Hi,
>
>Could someone please explain to me the concept of an anonymous class?
>
>I'm talking about this construct:
>
>class << Foo
>...
>end
>
>I'm having a hard time understanding the books and figuring out when I
>might actually want/need to use this.
>
>Ian
>
>
[url]http://www.rubygarden.org/ruby?ClassMethods[/url]
Chad
Chad Fowler Guest
-
Ian Macdonald #3
Re: anonymous classes
On Tue 01 Jul 2003 at 19:04:23 +0900, Brian Candler wrote:
Thanks. This is an excellent resource and makes things a lot clearer.> On Tue, Jul 01, 2003 at 08:50:31AM +0900, Ian Macdonald wrote:>> > Hi,
> >
> > Could someone please explain to me the concept of an anonymous class?
> >
> > I'm talking about this construct:
> >
> > class << Foo
> > ...
> > end
> >
> > I'm having a hard time understanding the books and figuring out when I
> > might actually want/need to use this.
> What you've written is called a "singleton class". I wrote this a while:
>
> [url]http://www.rubygarden.org/ruby?SingletonTutorial[/url]
>
> It might be helpful and includes a couple of links to more detailled
> information.
Ian
--
Ian Macdonald | Yes, we will be going to OSI, Mars, and
System Administrator | Pluto, but not necessarily in that order.
[email]ian@caliban.org[/email] | -- Jeffrey Honig
[url]http://www.caliban.org[/url] |
|
Ian Macdonald Guest
-
Dominik Werder #4
Re: anonymous classes
> What you've written is called a "singleton class". I wrote this a while:
>
> [url]http://www.rubygarden.org/ruby?SingletonTutorial[/url]
it is very helpful for me too :)
One question referring to
"A neat solution then is to create a singleton class for each POP3
connection as it arrives: "
How much memory does this technique consume? Are the new methods created
for each individual instance? Or just something like a lookup table?
bye!
Dominik
Dominik Werder Guest
-
Brian Candler #5
Re: anonymous classes
On Wed, Jul 02, 2003 at 05:36:21PM +0900, Dominik Werder wrote:
All that happens is that a new proxy class is added to the object, which>> > What you've written is called a "singleton class". I wrote this a while:
> >
> > [url]http://www.rubygarden.org/ruby?SingletonTutorial[/url]
>
> it is very helpful for me too :)
>
> One question referring to
> "A neat solution then is to create a singleton class for each POP3
> connection as it arrives: "
> How much memory does this technique consume? Are the new methods created
> for each individual instance? Or just something like a lookup table?
points at the module which you #extended it with. It certainly doesn't copy
all the methods.
You can prove this easily enough, by modifying the module *after* you have
done extend:
module A
end
a = "hello"
a.extend A
b = "world"
b.extend A
module A
def foo
puts "it works"
end
end
a.foo #=> "it works"
b.foo #=> "it works"
You can see that the two objects share the same module implementation.
Regards,
Brian.
Brian Candler Guest



Reply With Quote

