In order to remove a class, I have to use Object.instance_eval
{ remove_const }
Why couldn’t I just use remove_const or Object.remove_const ?
In order to remove a class, I have to use Object.instance_eval
{ remove_const }
Why couldn’t I just use remove_const or Object.remove_const ?
On Tue, Sep 22, 2009 at 3:30 PM, jko170 [email protected] wrote:
In order to remove a class, I have to use Object.instance_eval
{ remove_const }Why couldn’t I just use remove_const or Object.remove_const ?
Module#remove_const is private.
remove_const :Foo
is sent to the top-level object which is not a module.
Object.remove_const :Foo
fails because the method is private.
Object.instance_eval {remove_const :Foo}
is one way of getting around the privacy, another would be
Object.send(:remove_const :Foo}
HTH
–
Rick DeNatale
Blog: http://talklikeaduck.denhaven2.com/
Twitter: http://twitter.com/RickDeNatale
WWR: http://www.workingwithrails.com/person/9021-rick-denatale
LinkedIn: http://www.linkedin.com/in/rickdenatale
This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.
Sponsor our Newsletter | Privacy Policy | Terms of Service | Remote Ruby Jobs