Browse files

Cleaned up the #default_helper_module method to make better use of #h…

…elper instead of duplicating code.
  • Loading branch information...
1 parent 37be453 commit 316fab7de66041daf616a7126d1a9f293a928144 Yehuda Katz + Carl Lerche committed Jun 10, 2009
Showing with 6 additions and 9 deletions.
  1. +6 −9 actionpack/lib/action_controller/new_base/helpers.rb
View
15 actionpack/lib/action_controller/new_base/helpers.rb
@@ -16,7 +16,7 @@ module Helpers
module ClassMethods
def inherited(klass)
- klass.__send__ :default_helper_module!
+ klass.class_eval { default_helper_module! unless name.blank? }
super
end
@@ -92,16 +92,13 @@ def _modules_for_helpers(args)
end
def default_helper_module!
- unless name.blank?
- module_name = name.sub(/Controller$|$/, 'Helper')
- module_path = module_name.split('::').map { |m| m.underscore }.join('/')
- require_dependency module_path
- helper module_name.constantize
- end
+ module_name = name.sub(/Controller$/, '')
+ module_path = module_name.underscore
+ helper module_path
rescue MissingSourceFile => e
- raise e unless e.is_missing? module_path
+ raise e unless e.is_missing? "#{module_path}_helper"
rescue NameError => e
- raise e unless e.missing_name? module_name
+ raise e unless e.missing_name? "#{module_name}Helper"
end
# Extract helper names from files in app/helpers/**/*.rb

0 comments on commit 316fab7

Please sign in to comment.