aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/new_base
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack/lib/action_controller/new_base')
-rw-r--r--actionpack/lib/action_controller/new_base/base.rb27
-rw-r--r--actionpack/lib/action_controller/new_base/hide_actions.rb11
-rw-r--r--actionpack/lib/action_controller/new_base/layouts.rb14
-rw-r--r--actionpack/lib/action_controller/new_base/renderer.rb23
-rw-r--r--actionpack/lib/action_controller/new_base/url_for.rb6
5 files changed, 43 insertions, 38 deletions
diff --git a/actionpack/lib/action_controller/new_base/base.rb b/actionpack/lib/action_controller/new_base/base.rb
index 2dd5390c99..08e7a1a0e7 100644
--- a/actionpack/lib/action_controller/new_base/base.rb
+++ b/actionpack/lib/action_controller/new_base/base.rb
@@ -1,5 +1,6 @@
module ActionController
class AbstractBase < AbstractController::Base
+
# :api: public
attr_internal :request, :response, :params
@@ -11,46 +12,46 @@ module ActionController
# :api: public
def controller_name() self.class.controller_name end
- # :api: public
+ # :api: public
def self.controller_path
@controller_path ||= self.name.sub(/Controller$/, '').underscore
end
-
- # :api: public
+
+ # :api: public
def controller_path() self.class.controller_path end
-
- # :api: private
+
+ # :api: private
def self.action_methods
@action_names ||= Set.new(self.public_instance_methods - self::CORE_METHODS)
end
-
- # :api: private
+
+ # :api: private
def self.action_names() action_methods end
-
- # :api: private
+
+ # :api: private
def action_methods() self.class.action_names end
# :api: private
def action_names() action_methods end
-
+
# :api: plugin
def self.call(env)
controller = new
controller.call(env).to_rack
end
-
+
# :api: plugin
def response_body=(body)
@_response.body = body
end
-
+
# :api: private
def call(env)
@_request = ActionDispatch::Request.new(env)
@_response = ActionDispatch::Response.new
process(@_request.parameters[:action])
end
-
+
# :api: private
def to_rack
response.to_a
diff --git a/actionpack/lib/action_controller/new_base/hide_actions.rb b/actionpack/lib/action_controller/new_base/hide_actions.rb
index 422ea180c4..aa420442fb 100644
--- a/actionpack/lib/action_controller/new_base/hide_actions.rb
+++ b/actionpack/lib/action_controller/new_base/hide_actions.rb
@@ -6,20 +6,21 @@ module ActionController
end
def action_methods() self.class.action_names end
- def action_names() action_methods end
-
+ def action_names() action_methods end
+
private
+
def respond_to_action?(action_name)
!hidden_actions.include?(action_name) && (super || respond_to?(:method_missing))
end
-
+
module ClassMethods
def hide_action(*args)
args.each do |arg|
self.hidden_actions << arg.to_s
end
end
-
+
def action_methods
@action_names ||= Set.new(super.reject {|name| self.hidden_actions.include?(name.to_s)})
end
@@ -27,4 +28,4 @@ module ActionController
def self.action_names() action_methods end
end
end
-end
+end \ No newline at end of file
diff --git a/actionpack/lib/action_controller/new_base/layouts.rb b/actionpack/lib/action_controller/new_base/layouts.rb
index 228162421d..89d24fe92d 100644
--- a/actionpack/lib/action_controller/new_base/layouts.rb
+++ b/actionpack/lib/action_controller/new_base/layouts.rb
@@ -4,13 +4,13 @@ module ActionController
depends_on ActionController::Renderer
depends_on AbstractController::Layouts
-
+
module ClassMethods
def _implied_layout_name
controller_path
end
end
-
+
def render_to_body(options)
# render :text => ..., :layout => ...
# or
@@ -18,20 +18,22 @@ module ActionController
if !options.key?(:text) || options.key?(:layout)
options[:_layout] = options.key?(:layout) ? _layout_for_option(options[:layout]) : _default_layout
end
-
+
super
end
-
+
private
+
def _layout_for_option(name)
case name
when String then _layout_for_name(name)
when true then _default_layout(true)
when false, nil then nil
else
- raise ArgumentError,
- "String, true, or false, expected for `layout'; you passed #{name.inspect}"
+ raise ArgumentError,
+ "String, true, or false, expected for `layout'; you passed #{name.inspect}"
end
end
+
end
end
diff --git a/actionpack/lib/action_controller/new_base/renderer.rb b/actionpack/lib/action_controller/new_base/renderer.rb
index d7ea9ec4a5..be4ea54c3b 100644
--- a/actionpack/lib/action_controller/new_base/renderer.rb
+++ b/actionpack/lib/action_controller/new_base/renderer.rb
@@ -3,22 +3,22 @@ module ActionController
extend ActiveSupport::DependencyModule
depends_on AbstractController::Renderer
-
+
def initialize(*)
self.formats = [:html]
super
end
-
+
def render(action, options = {})
# TODO: Move this into #render_to_body
if action.is_a?(Hash)
- options, action = action, nil
+ options, action = action, nil
else
options.merge! :action => action
end
-
+
_process_options(options)
-
+
self.response_body = render_to_body(options)
end
@@ -34,17 +34,18 @@ module ActionController
options[:_template_name] = options[:template]
elsif options.key?(:action)
options[:_template_name] = options[:action].to_s
- options[:_prefix] = _prefix
+ options[:_prefix] = _prefix
end
-
+
super(options)
end
-
+
private
+
def _prefix
controller_path
- end
-
+ end
+
def _text(options)
text = options[:text]
@@ -53,7 +54,7 @@ module ActionController
else text.to_s
end
end
-
+
def _process_options(options)
if status = options[:status]
response.status = status.to_i
diff --git a/actionpack/lib/action_controller/new_base/url_for.rb b/actionpack/lib/action_controller/new_base/url_for.rb
index 3179c8cd5b..af5b21012b 100644
--- a/actionpack/lib/action_controller/new_base/url_for.rb
+++ b/actionpack/lib/action_controller/new_base/url_for.rb
@@ -16,7 +16,7 @@ module ActionController
# by this method.
def default_url_options(options = nil)
end
-
+
def rewrite_options(options) #:nodoc:
if defaults = default_url_options(options)
defaults.merge(options)
@@ -24,7 +24,7 @@ module ActionController
options
end
end
-
+
def url_for(options = {})
options ||= {}
case options
@@ -37,4 +37,4 @@ module ActionController
end
end
end
-end
+end \ No newline at end of file