From 157896e175a964145326a3b279780149b399b1c8 Mon Sep 17 00:00:00 2001 From: Bryan Larsen Date: Tue, 15 Dec 2009 15:37:43 -0600 Subject: [PATCH] [#576 state:resolved] Load rich types from plugins --- hobo/init.rb | 1 + hobo/lib/hobo/fake_initializer.rb | 14 -------------- hobo/taglibs/rapid_summary.dryml | 3 +-- hobofields/lib/hobo_fields.rb | 10 +++++++--- 4 files changed, 9 insertions(+), 19 deletions(-) delete mode 100644 hobo/lib/hobo/fake_initializer.rb diff --git a/hobo/init.rb b/hobo/init.rb index 240b29e..7a3dd84 100644 --- a/hobo/init.rb +++ b/hobo/init.rb @@ -1,2 +1,3 @@ +::RAILS_INITIALIZER = initializer require File.dirname(__FILE__) + "/lib/hobo" require 'rails_generator' diff --git a/hobo/lib/hobo/fake_initializer.rb b/hobo/lib/hobo/fake_initializer.rb deleted file mode 100644 index bdaf44a..0000000 --- a/hobo/lib/hobo/fake_initializer.rb +++ /dev/null @@ -1,14 +0,0 @@ -# really what we want is a reference to the Initializer used in -# config/boot.rb. But since we can't monkey patch that file, we'll -# use a fake instead. - -# this is used by the rapid_summary tag with_plugins -module Hobo - class FakeInitializer - attr_reader :configuration - - def initialize(config = Rails.configuration) - @configuration = config - end - end -end diff --git a/hobo/taglibs/rapid_summary.dryml b/hobo/taglibs/rapid_summary.dryml index 157b233..113bef1 100644 --- a/hobo/taglibs/rapid_summary.dryml +++ b/hobo/taglibs/rapid_summary.dryml @@ -129,8 +129,7 @@ - <% fi = Hobo::FakeInitializer.new(Rails.configuration) - plugins = Rails.configuration.plugin_loader.new(fi).plugins %> + <% plugins = Rails.configuration.plugin_loader.new(RAILS_INITIALIZER).plugins %> diff --git a/hobofields/lib/hobo_fields.rb b/hobofields/lib/hobo_fields.rb index 8291b1a..54853b1 100644 --- a/hobofields/lib/hobo_fields.rb +++ b/hobofields/lib/hobo_fields.rb @@ -103,10 +103,14 @@ module HoboFields # automatically load other rich types from app/rich_types/*.rb # don't assume we're in a Rails app if defined?(::Rails) - Dir[File.join(::Rails.root, 'app', 'rich_types', '*.rb')].each do |f| - # TODO: should we complain if field_types doesn't get a new value? Might be useful to warn people if they're missing a register_type - require f + plugins = Rails.configuration.plugin_loader.new(RAILS_INITIALIZER).plugins + ([::Rails.root] + plugins.map(&:directory)).each do |dir| + Dir[File.join(dir, 'app', 'rich_types', '*.rb')].each do |f| + # TODO: should we complain if field_types doesn't get a new value? Might be useful to warn people if they're missing a register_type + require f + end end + end # Monkey patch ActiveRecord so that the attribute read & write methods -- 1.6.3.3