2009-06-15 14:44:45 -04:00
|
|
|
module ActionController
|
2009-08-06 18:50:22 -04:00
|
|
|
class Base < Metal
|
2009-06-15 14:44:45 -04:00
|
|
|
abstract!
|
|
|
|
|
|
|
|
include AbstractController::Callbacks
|
2009-12-30 19:33:54 -05:00
|
|
|
include AbstractController::Layouts
|
2010-01-20 08:41:23 -05:00
|
|
|
include AbstractController::Translation
|
2009-06-15 14:44:45 -04:00
|
|
|
|
|
|
|
include ActionController::Helpers
|
2010-01-03 21:32:02 -05:00
|
|
|
helper :all # By default, all helpers should be included
|
|
|
|
|
2009-06-15 14:44:45 -04:00
|
|
|
include ActionController::HideActions
|
|
|
|
include ActionController::UrlFor
|
2009-12-20 20:25:13 -05:00
|
|
|
include ActionController::Redirecting
|
2009-12-20 20:15:31 -05:00
|
|
|
include ActionController::Rendering
|
2009-12-20 21:15:20 -05:00
|
|
|
include ActionController::Renderers::All
|
2009-06-15 14:44:45 -04:00
|
|
|
include ActionController::ConditionalGet
|
2009-12-20 21:05:26 -05:00
|
|
|
include ActionController::RackDelegation
|
2009-10-26 18:47:08 -04:00
|
|
|
include ActionController::Configuration
|
2009-06-15 14:44:45 -04:00
|
|
|
|
|
|
|
# Legacy modules
|
|
|
|
include SessionManagement
|
|
|
|
include ActionController::Caching
|
|
|
|
include ActionController::MimeResponds
|
|
|
|
|
|
|
|
# Rails 2.x compatibility
|
2009-12-02 23:01:01 -05:00
|
|
|
include ActionController::Compatibility
|
2009-06-15 14:44:45 -04:00
|
|
|
|
|
|
|
include ActionController::Cookies
|
2010-01-19 06:52:10 -05:00
|
|
|
include ActionController::FilterParameterLogging
|
2009-06-15 14:44:45 -04:00
|
|
|
include ActionController::Flash
|
|
|
|
include ActionController::Verification
|
|
|
|
include ActionController::RequestForgeryProtection
|
|
|
|
include ActionController::Streaming
|
|
|
|
include ActionController::HttpAuthentication::Basic::ControllerMethods
|
|
|
|
include ActionController::HttpAuthentication::Digest::ControllerMethods
|
|
|
|
|
2010-01-12 18:41:04 -05:00
|
|
|
# Add instrumentations hooks at the bottom, to ensure they instrument
|
|
|
|
# all the methods properly.
|
|
|
|
include ActionController::Instrumentation
|
|
|
|
|
2009-06-15 14:44:45 -04:00
|
|
|
# TODO: Extract into its own module
|
|
|
|
# This should be moved together with other normalizing behavior
|
|
|
|
module ImplicitRender
|
|
|
|
def send_action(*)
|
|
|
|
ret = super
|
2009-08-09 02:05:04 -04:00
|
|
|
default_render unless response_body
|
2009-06-15 14:44:45 -04:00
|
|
|
ret
|
|
|
|
end
|
|
|
|
|
|
|
|
def default_render
|
|
|
|
render
|
2007-02-04 17:27:45 -05:00
|
|
|
end
|
2008-05-14 14:00:09 -04:00
|
|
|
|
2009-06-15 14:44:45 -04:00
|
|
|
def method_for_action(action_name)
|
|
|
|
super || begin
|
2009-09-03 15:41:28 -04:00
|
|
|
if template_exists?(action_name.to_s, {:formats => formats}, :_prefix => controller_path)
|
2009-06-15 14:44:45 -04:00
|
|
|
"default_render"
|
|
|
|
end
|
2009-04-23 18:58:38 -04:00
|
|
|
end
|
|
|
|
end
|
2004-11-23 20:04:44 -05:00
|
|
|
end
|
|
|
|
|
2009-06-15 14:44:45 -04:00
|
|
|
include ImplicitRender
|
2008-12-25 15:45:59 -05:00
|
|
|
|
2009-06-15 14:44:45 -04:00
|
|
|
include ActionController::Rescue
|
2006-08-07 02:11:56 -04:00
|
|
|
|
2009-06-15 14:44:45 -04:00
|
|
|
def self.inherited(klass)
|
|
|
|
::ActionController::Base.subclasses << klass.to_s
|
|
|
|
super
|
|
|
|
end
|
2008-11-01 07:16:15 -04:00
|
|
|
|
2009-06-15 14:44:45 -04:00
|
|
|
def self.subclasses
|
|
|
|
@subclasses ||= []
|
|
|
|
end
|
2008-11-01 07:16:15 -04:00
|
|
|
|
2010-01-20 08:21:27 -05:00
|
|
|
def _normalize_options(action=nil, options={}, &blk)
|
|
|
|
case action
|
|
|
|
when NilClass
|
|
|
|
when Hash, String
|
|
|
|
options = super
|
|
|
|
when Symbol
|
|
|
|
options.merge! :action => action
|
|
|
|
else
|
2009-06-15 14:44:45 -04:00
|
|
|
options.merge! :partial => action
|
2004-11-23 20:04:44 -05:00
|
|
|
end
|
2006-09-04 00:58:08 -04:00
|
|
|
|
2009-06-15 14:44:45 -04:00
|
|
|
if options.key?(:action) && options[:action].to_s.index("/")
|
|
|
|
options[:template] = options.delete(:action)
|
2005-01-20 09:13:34 -05:00
|
|
|
end
|
2004-11-23 20:04:44 -05:00
|
|
|
|
2009-06-15 14:44:45 -04:00
|
|
|
if options[:status]
|
2009-12-22 17:08:03 -05:00
|
|
|
options[:status] = Rack::Utils.status_code(options[:status])
|
2006-02-12 00:51:02 -05:00
|
|
|
end
|
2004-11-23 20:04:44 -05:00
|
|
|
|
2009-06-15 14:44:45 -04:00
|
|
|
options[:update] = blk if block_given?
|
|
|
|
options
|
|
|
|
end
|
2008-11-23 17:35:13 -05:00
|
|
|
end
|
2007-09-13 20:25:59 -04:00
|
|
|
end
|