madtrick
2008-Aug-31 23:06 UTC
Doubt at ActionController::Routing::RouteSet::NamedRouteCollection#clear!
I would like to know if anyone could explain me something: def clear! @routes = {} @helpers = [] @module ||= Module.new @module.instance_methods.each do |selector| @module.class_eval { remove_method selector } end end The thing I don''t understang clearly it''s why @module.instance_methods.each do ... it''s done since when we create an anonymous Module it has none instance methods: irb(main):017:0* m = Module.new => #<Module:0x5be78> irb(main):018:0> m.instance_methods => [] Any suggestions? Farruco Sanjurjo. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2008-Sep-01 09:04 UTC
Re: Doubt at ActionController::Routing::RouteSet::NamedRouteCollection#clear!
On Sep 1, 12:06 am, madtrick <madtr...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I would like to know if anyone could explain me something: > > def clear! > @routes = {} > @helpers = [] > > @module ||= Module.new > @module.instance_methods.each do |selector| > @module.class_eval { remove_method selector } > end > end > > The thing I don''t understang clearly it''s why > @module.instance_methods.each do ... it''s done since when we create an > anonymous Module it has none instance methods: >I don''t know this code at all, but module isn''t necessarily an empty module (since we''re doing ||=) Fred> irb(main):017:0* m = Module.new > => #<Module:0x5be78> > irb(main):018:0> m.instance_methods > => [] > > Any suggestions? > > Farruco Sanjurjo.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---