2009-06-15 18:44:45 +00:00
|
|
|
module ActionController
|
2009-08-06 22:50:22 +00:00
|
|
|
class Base < Metal
|
2009-06-15 18:44:45 +00:00
|
|
|
abstract!
|
|
|
|
|
|
|
|
include AbstractController::Callbacks
|
2009-12-31 00:33:54 +00:00
|
|
|
include AbstractController::Layouts
|
2009-06-15 18:44:45 +00:00
|
|
|
|
|
|
|
include ActionController::Helpers
|
2010-01-04 02:32:02 +00:00
|
|
|
helper :all # By default, all helpers should be included
|
|
|
|
|
2009-06-15 18:44:45 +00:00
|
|
|
include ActionController::HideActions
|
|
|
|
include ActionController::UrlFor
|
2009-12-21 01:25:13 +00:00
|
|
|
include ActionController::Redirecting
|
2009-12-21 01:15:31 +00:00
|
|
|
include ActionController::Rendering
|
2009-12-21 02:15:20 +00:00
|
|
|
include ActionController::Renderers::All
|
2009-06-15 18:44:45 +00:00
|
|
|
include ActionController::ConditionalGet
|
2009-12-21 02:05:26 +00:00
|
|
|
include ActionController::RackDelegation
|
2009-12-22 19:17:27 +00:00
|
|
|
include ActionController::Logger
|
2009-10-26 22:47:08 +00:00
|
|
|
include ActionController::Configuration
|
2009-06-15 18:44:45 +00:00
|
|
|
|
|
|
|
# Legacy modules
|
|
|
|
include SessionManagement
|
|
|
|
include ActionController::Caching
|
|
|
|
include ActionController::MimeResponds
|
|
|
|
|
|
|
|
# Rails 2.x compatibility
|
2009-12-03 04:01:01 +00:00
|
|
|
include ActionController::Compatibility
|
2009-06-15 18:44:45 +00:00
|
|
|
|
|
|
|
include ActionController::Cookies
|
|
|
|
include ActionController::Flash
|
|
|
|
include ActionController::Verification
|
|
|
|
include ActionController::RequestForgeryProtection
|
|
|
|
include ActionController::Streaming
|
|
|
|
include ActionController::HttpAuthentication::Basic::ControllerMethods
|
|
|
|
include ActionController::HttpAuthentication::Digest::ControllerMethods
|
|
|
|
include ActionController::FilterParameterLogging
|
|
|
|
include ActionController::Translation
|
|
|
|
|
|
|
|
# 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 06:05:04 +00:00
|
|
|
default_render unless response_body
|
2009-06-15 18:44:45 +00:00
|
|
|
ret
|
|
|
|
end
|
|
|
|
|
|
|
|
def default_render
|
|
|
|
render
|
2007-02-04 22:27:45 +00:00
|
|
|
end
|
2008-05-14 18:00:09 +00:00
|
|
|
|
2009-06-15 18:44:45 +00:00
|
|
|
def method_for_action(action_name)
|
|
|
|
super || begin
|
2009-09-03 19:41:28 +00:00
|
|
|
if template_exists?(action_name.to_s, {:formats => formats}, :_prefix => controller_path)
|
2009-06-15 18:44:45 +00:00
|
|
|
"default_render"
|
|
|
|
end
|
2009-04-23 22:58:38 +00:00
|
|
|
end
|
|
|
|
end
|
2004-11-24 01:04:44 +00:00
|
|
|
end
|
|
|
|
|
2009-06-15 18:44:45 +00:00
|
|
|
include ImplicitRender
|
2008-12-25 20:45:59 +00:00
|
|
|
|
2009-06-15 18:44:45 +00:00
|
|
|
include ActionController::Rescue
|
2006-08-07 06:11:56 +00:00
|
|
|
|
2009-06-15 18:44:45 +00:00
|
|
|
def self.inherited(klass)
|
|
|
|
::ActionController::Base.subclasses << klass.to_s
|
|
|
|
super
|
|
|
|
end
|
2008-11-01 11:16:15 +00:00
|
|
|
|
2009-06-15 18:44:45 +00:00
|
|
|
def self.subclasses
|
|
|
|
@subclasses ||= []
|
|
|
|
end
|
2008-11-01 11:16:15 +00:00
|
|
|
|
2009-06-15 18:44:45 +00:00
|
|
|
def _normalize_options(action = nil, options = {}, &blk)
|
|
|
|
if action.is_a?(Hash)
|
|
|
|
options, action = action, nil
|
|
|
|
elsif action.is_a?(String) || action.is_a?(Symbol)
|
|
|
|
key = case action = action.to_s
|
|
|
|
when %r{^/} then :file
|
|
|
|
when %r{/} then :template
|
|
|
|
else :action
|
2004-11-24 01:04:44 +00:00
|
|
|
end
|
2009-06-15 18:44:45 +00:00
|
|
|
options.merge! key => action
|
|
|
|
elsif action
|
|
|
|
options.merge! :partial => action
|
2004-11-24 01:04:44 +00:00
|
|
|
end
|
2006-09-04 04:58:08 +00:00
|
|
|
|
2009-06-15 18:44:45 +00:00
|
|
|
if options.key?(:action) && options[:action].to_s.index("/")
|
|
|
|
options[:template] = options.delete(:action)
|
2005-01-20 14:13:34 +00:00
|
|
|
end
|
2004-11-24 01:04:44 +00:00
|
|
|
|
2009-06-15 18:44:45 +00:00
|
|
|
if options[:status]
|
2009-12-22 22:08:03 +00:00
|
|
|
options[:status] = Rack::Utils.status_code(options[:status])
|
2006-02-12 05:51:02 +00:00
|
|
|
end
|
2004-11-24 01:04:44 +00:00
|
|
|
|
2009-06-15 18:44:45 +00:00
|
|
|
options[:update] = blk if block_given?
|
|
|
|
options
|
|
|
|
end
|
2006-09-04 04:58:08 +00:00
|
|
|
|
2009-06-15 18:44:45 +00:00
|
|
|
def render(action = nil, options = {}, &blk)
|
|
|
|
options = _normalize_options(action, options, &blk)
|
|
|
|
super(options)
|
|
|
|
end
|
2006-02-12 05:51:02 +00:00
|
|
|
|
2009-06-15 18:44:45 +00:00
|
|
|
def render_to_string(action = nil, options = {}, &blk)
|
|
|
|
options = _normalize_options(action, options, &blk)
|
|
|
|
super(options)
|
|
|
|
end
|
2008-11-23 22:35:13 +00:00
|
|
|
end
|
2007-09-14 00:25:59 +00:00
|
|
|
end
|