diff options
author | Joshua Peek <josh@joshpeek.com> | 2009-05-29 16:06:21 -0500 |
---|---|---|
committer | Joshua Peek <josh@joshpeek.com> | 2009-05-29 16:06:21 -0500 |
commit | 69742ca8fa05509f7d7c5512cb6d8e002ecb3ab3 (patch) | |
tree | 044c2131cc87d21ee54027511aae2b7f2d2ae26a /actionpack/lib/action_controller/new_base/http.rb | |
parent | 5f3f100ce2d689480da85abc88e5e940cf90189e (diff) | |
parent | 5ec2c7dc29b36d85b2658465b8a979deb0529d7e (diff) | |
download | rails-69742ca8fa05509f7d7c5512cb6d8e002ecb3ab3.tar.gz rails-69742ca8fa05509f7d7c5512cb6d8e002ecb3ab3.tar.bz2 rails-69742ca8fa05509f7d7c5512cb6d8e002ecb3ab3.zip |
Merge branch 'master' into active_model
Conflicts:
activemodel/lib/active_model/core.rb
activemodel/test/cases/state_machine/event_test.rb
activemodel/test/cases/state_machine/state_transition_test.rb
activerecord/lib/active_record/validations.rb
activerecord/test/cases/validations/i18n_validation_test.rb
activeresource/lib/active_resource.rb
activeresource/test/abstract_unit.rb
Diffstat (limited to 'actionpack/lib/action_controller/new_base/http.rb')
-rw-r--r-- | actionpack/lib/action_controller/new_base/http.rb | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/actionpack/lib/action_controller/new_base/http.rb b/actionpack/lib/action_controller/new_base/http.rb new file mode 100644 index 0000000000..c96aaaa865 --- /dev/null +++ b/actionpack/lib/action_controller/new_base/http.rb @@ -0,0 +1,91 @@ +require 'action_controller/abstract' +require 'active_support/core_ext/module/delegation' + +module ActionController + class Http < AbstractController::Base + abstract! + + # :api: public + attr_internal :params, :env + + # :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_names + action_methods + end + + # :api: private + def action_names + action_methods + end + + # :api: plugin + def self.call(env) + controller = new + controller.call(env).to_rack + end + + # The details below can be overridden to support a specific + # Request and Response object. The default ActionController::Base + # implementation includes RackConvenience, which makes a request + # and response object available. You might wish to control the + # environment and response manually for performance reasons. + + attr_internal :status, :headers, :content_type + + def initialize(*) + @_headers = {} + super + end + + # Basic implements for content_type=, location=, and headers are + # provided to reduce the dependency on the RackConvenience module + # in Renderer and Redirector. + + def content_type=(type) + headers["Content-Type"] = type.to_s + end + + def location=(url) + headers["Location"] = url + end + + # :api: private + def call(name, env) + @_env = env + process(name) + to_rack + end + + # :api: private + def to_rack + [status, headers, response_body] + end + + def self.action(name) + @actions ||= {} + @actions[name.to_s] ||= proc do |env| + new.call(name, env) + end + end + end +end |