aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_controller/new_base
diff options
context:
space:
mode:
authorYehuda Katz <wycats@gmail.com>2009-03-17 18:04:22 -0700
committerYehuda Katz <wycats@gmail.com>2009-03-17 18:04:22 -0700
commitf55514125cae291791365effc856d237008f7cd2 (patch)
tree6080509ce323a5880b8b7552efc5d8f76afaade3 /actionpack/lib/action_controller/new_base
parenta2637e9f1fba92bc0b8dbf461ce9f4f8ffb4cfaa (diff)
downloadrails-f55514125cae291791365effc856d237008f7cd2.tar.gz
rails-f55514125cae291791365effc856d237008f7cd2.tar.bz2
rails-f55514125cae291791365effc856d237008f7cd2.zip
Working toward getting a basic AbstractController framework
Diffstat (limited to 'actionpack/lib/action_controller/new_base')
-rw-r--r--actionpack/lib/action_controller/new_base/base.rb37
-rw-r--r--actionpack/lib/action_controller/new_base/hide_actions.rb6
-rw-r--r--actionpack/lib/action_controller/new_base/renderer.rb11
3 files changed, 53 insertions, 1 deletions
diff --git a/actionpack/lib/action_controller/new_base/base.rb b/actionpack/lib/action_controller/new_base/base.rb
index ebe7c8dda6..0400ddbf7a 100644
--- a/actionpack/lib/action_controller/new_base/base.rb
+++ b/actionpack/lib/action_controller/new_base/base.rb
@@ -1,26 +1,61 @@
module ActionController
class AbstractBase < AbstractController::Base
+
+ # :api: public
attr_internal :request, :response, :params
+ # :api: public
def self.controller_name
@controller_name ||= controller_path.split("/").last
end
+ # :api: public
def controller_name() self.class.controller_name end
-
+
+ # :api: public
def self.controller_path
@controller_path ||= self.name.sub(/Controller$/, '').underscore
end
+ # :api: public
def controller_path() self.class.controller_path end
+ # :api: private
def self.action_methods
@action_names ||= Set.new(self.public_instance_methods - self::CORE_METHODS)
end
+ # :api: private
def self.action_names() action_methods end
+ # :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["Content-Length"] = body.length
+ @_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
+ end
end
end \ No newline at end of file
diff --git a/actionpack/lib/action_controller/new_base/hide_actions.rb b/actionpack/lib/action_controller/new_base/hide_actions.rb
index 9847d7b086..b3777c3c1e 100644
--- a/actionpack/lib/action_controller/new_base/hide_actions.rb
+++ b/actionpack/lib/action_controller/new_base/hide_actions.rb
@@ -10,6 +10,12 @@ module ActionController
def action_methods() self.class.action_names 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)
diff --git a/actionpack/lib/action_controller/new_base/renderer.rb b/actionpack/lib/action_controller/new_base/renderer.rb
new file mode 100644
index 0000000000..503450c246
--- /dev/null
+++ b/actionpack/lib/action_controller/new_base/renderer.rb
@@ -0,0 +1,11 @@
+module ActionController
+ module Renderer
+
+ def render(options)
+ if text = options[:text]
+ self.response_body = text
+ end
+ end
+
+ end
+end \ No newline at end of file