diff options
Diffstat (limited to 'actionpack/lib/action_controller/abstract')
5 files changed, 33 insertions, 40 deletions
diff --git a/actionpack/lib/action_controller/abstract/callbacks.rb b/actionpack/lib/action_controller/abstract/callbacks.rb index a88d4c1567..c8b509081c 100644 --- a/actionpack/lib/action_controller/abstract/callbacks.rb +++ b/actionpack/lib/action_controller/abstract/callbacks.rb @@ -1,11 +1,8 @@ module AbstractController module Callbacks - def self.included(klass) - klass.class_eval do - include ActiveSupport::NewCallbacks - define_callbacks :process_action - extend ClassMethods - end + setup do + include ActiveSupport::NewCallbacks + define_callbacks :process_action end def process_action diff --git a/actionpack/lib/action_controller/abstract/helpers.rb b/actionpack/lib/action_controller/abstract/helpers.rb index 1947c360b8..1f0b38417b 100644 --- a/actionpack/lib/action_controller/abstract/helpers.rb +++ b/actionpack/lib/action_controller/abstract/helpers.rb @@ -1,17 +1,18 @@ module AbstractController module Helpers - - def self.included(klass) - klass.class_eval do - extend ClassMethods - unless self < ::AbstractController::Renderer - raise "You need to include AbstractController::Renderer before including " \ - "AbstractController::Helpers" - end - extlib_inheritable_accessor :master_helper_module - self.master_helper_module = Module.new - end + depends_on Renderer + + setup do + extlib_inheritable_accessor :master_helper_module + self.master_helper_module = Module.new end + + # def self.included(klass) + # klass.class_eval do + # extlib_inheritable_accessor :master_helper_module + # self.master_helper_module = Module.new + # end + # end def _action_view @_action_view ||= begin diff --git a/actionpack/lib/action_controller/abstract/layouts.rb b/actionpack/lib/action_controller/abstract/layouts.rb index 20c9abb9e5..2680283151 100644 --- a/actionpack/lib/action_controller/abstract/layouts.rb +++ b/actionpack/lib/action_controller/abstract/layouts.rb @@ -1,25 +1,24 @@ module AbstractController module Layouts - def self.included(base) - base.extend ClassMethods - end - + depends_on Renderer + module ClassMethods 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 + @_layout = layout || false # Converts nil to false + _write_layout_method end def _write_layout_method - case @layout + case @_layout when String - self.class_eval %{def _layout() #{@layout.inspect} end} + self.class_eval %{def _layout() #{@_layout.inspect} end} when Symbol - self.class_eval %{def _layout() #{@layout} end} + self.class_eval %{def _layout() #{@_layout} end} when false self.class_eval %{def _layout() end} else @@ -43,7 +42,7 @@ module AbstractController private def _layout() end # This will be overwritten - + def _layout_for_option(name) case name when String then _layout_for_name(name) diff --git a/actionpack/lib/action_controller/abstract/logger.rb b/actionpack/lib/action_controller/abstract/logger.rb index 846d8ad040..4117369bd4 100644 --- a/actionpack/lib/action_controller/abstract/logger.rb +++ b/actionpack/lib/action_controller/abstract/logger.rb @@ -1,7 +1,7 @@ module AbstractController module Logger - def self.included(klass) - klass.cattr_accessor :logger + setup do + cattr_accessor :logger end end end
\ No newline at end of file diff --git a/actionpack/lib/action_controller/abstract/renderer.rb b/actionpack/lib/action_controller/abstract/renderer.rb index 5daade6109..68c3b07b84 100644 --- a/actionpack/lib/action_controller/abstract/renderer.rb +++ b/actionpack/lib/action_controller/abstract/renderer.rb @@ -2,20 +2,16 @@ require "action_controller/abstract/logger" module AbstractController module Renderer + depends_on AbstractController::Logger - def self.included(klass) - klass.class_eval do - extend ClassMethods - - attr_internal :formats - - extlib_inheritable_accessor :_view_paths - - self._view_paths ||= ActionView::PathSet.new - include AbstractController::Logger - end + setup do + attr_internal :formats + + extlib_inheritable_accessor :_view_paths + + self._view_paths ||= ActionView::PathSet.new end - + def _action_view @_action_view ||= ActionView::Base.new(self.class.view_paths, {}, self) end |