diff options
author | Yehuda Katz and Carl Lerche <wycats@gmail.com> | 2009-03-23 18:06:47 -0700 |
---|---|---|
committer | Yehuda Katz and Carl Lerche <wycats@gmail.com> | 2009-03-23 18:06:47 -0700 |
commit | 1d3e2c2b7333c90f2ef26fd0a3c6184aeaeb7e8a (patch) | |
tree | 35ae0a1a2e8cd0ed3a105fbc08ddcc08014cb976 /actionpack/lib/action_controller/abstract | |
parent | a501638e9dcf55e45613637c52e4169b6324f285 (diff) | |
download | rails-1d3e2c2b7333c90f2ef26fd0a3c6184aeaeb7e8a.tar.gz rails-1d3e2c2b7333c90f2ef26fd0a3c6184aeaeb7e8a.tar.bz2 rails-1d3e2c2b7333c90f2ef26fd0a3c6184aeaeb7e8a.zip |
In the middle of some refactoring... some fails due to changes in AbstractController not yet reflected in ActionController tests
Diffstat (limited to 'actionpack/lib/action_controller/abstract')
-rw-r--r-- | actionpack/lib/action_controller/abstract/layouts.rb | 42 |
1 files changed, 31 insertions, 11 deletions
diff --git a/actionpack/lib/action_controller/abstract/layouts.rb b/actionpack/lib/action_controller/abstract/layouts.rb index 29b610610f..20c9abb9e5 100644 --- a/actionpack/lib/action_controller/abstract/layouts.rb +++ b/actionpack/lib/action_controller/abstract/layouts.rb @@ -6,7 +6,34 @@ module AbstractController end module ClassMethods - def _layout() end + def layout(layout) + unless [String, Symbol, FalseClass, NilClass].include?(layout.class) + raise ArgumentError, "Layouts must be specified as a String, Symbol, false, or nil" + end + + @layout = layout || false # Converts nil to false + end + + def _write_layout_method + case @layout + when String + self.class_eval %{def _layout() #{@layout.inspect} end} + when Symbol + self.class_eval %{def _layout() #{@layout} end} + when false + self.class_eval %{def _layout() end} + else + self.class_eval %{ + def _layout + if view_paths.find_by_parts?("#{controller_path}", formats, "layouts") + "#{controller_path}" + else + super + end + end + } + end + end end def _render_template(template, options) @@ -14,6 +41,8 @@ module AbstractController end private + + def _layout() end # This will be overwritten def _layout_for_option(name) case name @@ -28,16 +57,7 @@ module AbstractController end def _default_layout(require_layout = false) - # begin - # _layout_for_name(controller_path) - # rescue ActionView::MissingTemplate - # begin - # _layout_for_name("application") - # rescue ActionView::MissingTemplate => e - # raise e if require_layout - # end - # end - _layout_for_option(self.class._layout) + _layout_for_option(_layout) end end end
\ No newline at end of file |