Rich types should be loaded from plugins
Reported by Matt Jones | December 8th, 2009 @ 09:30 PM | in Hobo 1.0 - Final
The rich types loader should look in plugins for types.
Most likely place to put them is app/rich_types; this matches the Rails 2.3 behavior of autoloading MVC stuff from a plugin's app/ directory.
Note that just loading from vendor/plugins/**/app/rich_types isn't sufficient, as system gems can also hook into the plugin system. There's a function in Railties to do the correct search.
Comments and changes to this ticket
-
Bryan Larsen December 8th, 2009 @ 09:49 PM
how about
Rails.configuration.plugin_loader.new(Hobo::FakeInitializer.new(Rails.configuration)).plugins.*.directory
If you find something better, let me know, because that code is stolen from hobo/taglibs/rapid_summary.dryml.
-
Bryan Larsen December 15th, 2009 @ 09:38 PM
- no changes were found...
-
Matt Jones December 15th, 2009 @ 11:07 PM
The best place to capture this, oddly enough, is in hobo/hobo/init.rb - it gets called with the initializer in scope!
So doing (the global is a terrible idea, but OK for trying it out):
$something = initializer
will stash the real Rails instance away. No idea if this will leak memory, but it's better than futzing around with a fake...
Edit: also note that once one has the initializer instance, a quick way to grab the plugins we're interested in is @initializer.plugin_loader.engines, which selects all the plugins that have an app/ directory. Only exists in 2.3.x, AFAIK.
-
Bryan Larsen December 15th, 2009 @ 11:58 PM
That's pretty much what I have -- the problem I'm having is stashing the initializer somewhere that isn't a global or a global constant. If I open up the Hobo module to stash it in there, the
require 'hobo'
line seems to be clearing it off. init.rb:module Hobo ; class << self ; attr_accessor :rails_initializer ; end ; end Hobo.rails_initializer = initializer require File.dirname(__FILE__) + "/lib/hobo" require 'rails_generator'
Any suggestions?
-
Matt Jones December 16th, 2009 @ 02:07 AM
At least over here, qualifying the Hobo constant to the toplevel (::Hobo) in the above works; it seems like init.rb is evaluated in a weird context.
-
Bryan Larsen December 16th, 2009 @ 03:42 AM
That's annoying. I did try ::Hobo but I must have had something else wrong. Thanks for prompting me to try it again. With those modifications, do you have any issues with the patch?
-
Matt Jones December 16th, 2009 @ 08:34 PM
Looks sensible - it might be worthwhile to encapsulate the "iterate over all the plugins with an app directory" idiom, as it's going to be needed for the other plugin loading ticket.
-
Bryan Larsen December 17th, 2009 @ 04:33 AM
- State changed from new to resolved
(from [b88fca4588a42120830982700ca62db51b302ffe]) [#576 state:resolved] Load rich types from plugins http://github.com/tablatom/hobo/commit/b88fca4588a42120830982700ca6...
Please Sign in or create a free account to add a new ticket.
With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป
People watching this ticket
Attachments
Tags
Referenced by
- 576 Rich types should be loaded from plugins (from [b88fca4588a42120830982700ca62db51b302ffe]) [#576 s...