[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

hook for class creation

Its Me

11/10/2004 6:58:00 PM

Is there a hook method called whenever a new class is created i.e.
guaranteed called for every new instance of Class ?

Class#initialize does not work.

Thanks.


10 Answers

Florian Gross

11/10/2004 7:30:00 PM

0

itsme213 wrote:

> Is there a hook method called whenever a new class is created i.e.
> guaranteed called for every new instance of Class ?

You can try Object.inherited, but I'm not sure if it will get called
when a class is created internally in C code.

Plus it can be overridden in subclasses so there is no 100% guarantee of
it getting called.

Its Me

11/10/2004 7:40:00 PM

0

Ah. Considering your suggestion I realized that I really wanted a hook for
just when my classes were created. So MyBase#inherited or MyMod#included are
good hooks.

Thanks!

p.s. the solution to my earlier question on clean-up for eval'ing named
class definitions in unit tests turned out to be
Module#remove_const

"Florian Gross" <flgr@ccan.de> wrote in message
news:2vf8hfF2li20bU1@uni-berlin.de...
> itsme213 wrote:
>
> > Is there a hook method called whenever a new class is created i.e.
> > guaranteed called for every new instance of Class ?
>
> You can try Object.inherited, but I'm not sure if it will get called
> when a class is created internally in C code.
>
> Plus it can be overridden in subclasses so there is no 100% guarantee of
> it getting called.


Jamis Buck

11/10/2004 7:57:00 PM

0

Florian Gross wrote:
> itsme213 wrote:
>
>> Is there a hook method called whenever a new class is created i.e.
>> guaranteed called for every new instance of Class ?
>
>
> You can try Object.inherited, but I'm not sure if it will get called
> when a class is created internally in C code.
>
> Plus it can be overridden in subclasses so there is no 100% guarantee of
> it getting called.
>
> .
>

What about just putting the initialization code in the class definition?

class Foo
def bar
...
end
...
# class init
do_something
do_something_else
end

- Jamis

--
Jamis Buck
jgb3@email.byu.edu
http://www.jamisbuck...


Robert Klemme

11/11/2004 11:00:00 AM

0


"Jamis Buck" <jgb3@email.byu.edu> schrieb im Newsbeitrag
news:41927269.1020701@email.byu.edu...
> Florian Gross wrote:
> > itsme213 wrote:
> >
> >> Is there a hook method called whenever a new class is created i.e.
> >> guaranteed called for every new instance of Class ?
> >
> >
> > You can try Object.inherited, but I'm not sure if it will get called
> > when a class is created internally in C code.
> >
> > Plus it can be overridden in subclasses so there is no 100% guarantee
of
> > it getting called.
> >
> > .
> >
>
> What about just putting the initialization code in the class definition?
>
> class Foo
> def bar
> ...
> end
> ...
> # class init
> do_something
> do_something_else
> end

I think 213 wanted some automated mechanism, so you can't forget it when
you create a new class.

robert

conwaycaine

8/18/2009 5:55:00 PM

0


"Akins of that Ilk" <stevenakins@bellsouth.net> wrote in message
news:eea222e4-64a9-4f03-a6c6-49346a160e0b@a26g2000yqn.googlegroups.com...
On Aug 16, 10:41 am, "conwaycaine" <conwayca...@bellsouth.net> wrote:
> "Akins of that Ilk" <stevenak...@bellsouth.net> wrote in
> messagenews:7e77c75a-3e13-4616-904d-efd4d0f17e59@c1g2000yqi.googlegroups.com...
>
> It's not as if I am hanging coloreds from the nearest lamp-post or
> anything.
>
> *****
>
> Ah but you see, your attitude leads to lynchings.

And you attitude leads to the destruction of the White race.

******

There is no white race.
Go get a comprehensive DNA check run
You may just experience a change of heart.


conwaycaine

8/18/2009 5:57:00 PM

0


"Ruiseart agus Ceit" <kerrie.alcorn@btinternet.com> wrote in message
news:zpGdnePC1I1boxXXnZ2dnUVZ8sudnZ2d@bt.com...
> "Akins of that Ilk" <stevenakins@bellsouth.net> wrote in message On Aug
> 16, 10:41 am, "conwaycaine" <conwayca...@bellsouth.net> wrote:
>
> And you attitude leads to the destruction of the White race.
> ******************************************************************************************
>
> The "White race" only came about as a result of evolution as we moved from
> Africa to a colder climate. There is nothing to "destroy" - we are all
> human.

It must be hell to wake up one morning and realize that one hates a couple
or three billion people for no good reason at all.
Other than for the fact they are there.


conwaycaine

8/18/2009 6:03:00 PM

0


"Fred J. McCall" <fjmccall@gmail.com> wrote in message
news:bbpg855vmrd0jb7ogniq3g8q0bfstedg1m@4ax.com...
> "conwaycaine" <conwaycaine@bellsouth.net> wrote:
> :"Akins of that Ilk" <stevenakins@bellsouth.net> wrote in message
> :
> :It's not as if I am hanging coloreds from the nearest lamp-post or
> :anything.
> :
> :*****
> :
> :Ah but you see, your attitude leads to lynchings.
> :
>
> And is thus just another way of collecting similar cowards together to
> do something they don't have the balls to do when they don't have a
> mob to reinforce them.
>
> If someone needs killing you don't take a mob along to the event and
> 'lynching' is just unnecessary drama.

Apparently Akins does not realize that his comments and his evidenced
prejudices are recorded here on the Net for ages to come.
When his great grandchildren decide to research the net to get a take on him
(and they will) there will be his ignorance and bigotry exposed for them to
see and realize
"Gramps was a nutter!!!!"


Deirdre Sholto Douglas

8/18/2009 7:04:00 PM

0

conwaycaine wrote:

> Apparently Akins does not realize that his comments and his evidenced
> prejudices are recorded here on the Net for ages to come.
> When his great grandchildren decide to research the net to get a take on him
> (and they will) there will be his ignorance and bigotry exposed for them to
> see and realize
> "Gramps was a nutter!!!!"

<shrug> More likely they'll simply say it's a common
enough name and deny any connection...after all, his
grandchildren are going to outlive him by a good bit
and they'll have plenty of time to break the nose off
his statue.

Deirdre

________________
Shamans and Wiccans and Druids...oh my!

Fred J. McCall

8/19/2009 2:39:00 AM

0

"conwaycaine" <conwaycaine@bellsouth.net> wrote:

:
:"Akins of that Ilk" <stevenakins@bellsouth.net> wrote in message
:news:eea222e4-64a9-4f03-a6c6-49346a160e0b@a26g2000yqn.googlegroups.com...
:On Aug 16, 10:41 am, "conwaycaine" <conwayca...@bellsouth.net> wrote:
:> "Akins of that Ilk" <stevenak...@bellsouth.net> wrote in
:> messagenews:7e77c75a-3e13-4616-904d-efd4d0f17e59@c1g2000yqi.googlegroups.com...
:>
:> It's not as if I am hanging coloreds from the nearest lamp-post or
:> anything.
:>
:> *****
:>
:> Ah but you see, your attitude leads to lynchings.
:
:And you attitude leads to the destruction of the White race.
:
:******
:
:There is no white race.
:Go get a comprehensive DNA check run
:You may just experience a change of heart.
:

Probably afraid he won't come up 'human', Conway...

--
You are
What you do
When it counts.

conwaycaine

8/19/2009 12:32:00 PM

0


"Deirdre Sholto Douglas" <finch.enteract@sbcglobal.net> wrote in message
news:7f0c9nF2hoajkU2@mid.individual.net...
> conwaycaine wrote:
>
>> Apparently Akins does not realize that his comments and his evidenced
>> prejudices are recorded here on the Net for ages to come.
>> When his great grandchildren decide to research the net to get a take on
>> him (and they will) there will be his ignorance and bigotry exposed for
>> them to see and realize
>> "Gramps was a nutter!!!!"
>
> <shrug> More likely they'll simply say it's a common
> enough name and deny any connection...after all, his
> grandchildren are going to outlive him by a good bit
> and they'll have plenty of time to break the nose off
> his statue.

And the badger heads off his sporran as well...........