I want to build a navigation system for my Rails app that using techniques
found in these articles:
http://wiki.rubyonrails.com/rails/show/HowToMakeSitemapWithIntrospection
http://wiki.rubyonrails.com/rails/show/DiscoveringControllersAndActions
My problem with those solutions is that it seems awfully wasteful to "load"
each controller just so that it's visible to the ObjectSpace object. My
understanding is at that point it's loaded, is this an incorrect assumption?
In C# you can use Reflection by pointing to an assembly (dll) and I'm
curious if Ruby has something similar.
So, taking something from the above options here is some really rough psuedo
code:
Find.find( RAILS_ROOT + 'app/controllers' ) do |file_name|
open file-_name
if of type Admin::BaseController
add to controllers array
end
loop controllers array
output found controllers.
If I'm going about this completely wrong and you know how I can do this
better by all means, let me know.
As I said, I'm learning Ruby and I'm just trying to learn how to do stuff. I
would imagine I'm not doing things the best way possible.
Kyle Heon
(e-mail address removed)
-----Original Message-----
From: Robert Klemme [mailto:
[email protected]]
Sent: Sunday, July 10, 2005 6:11 AM
To: ruby-talk ML
Subject: Re: Reflection of an unloaded class/object
Kyle Heon said:
Is it possible to look inside an object without it having already been
loaded into memory? In other words, can you do so by file path instead
of having it look at what is currently loaded?
What exactly do you mean by "look inside an object"? What is it that you
are trying to achieve?
Kind regards
robert