aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/examples/minimal.rb34
-rw-r--r--actionpack/examples/simple.rb17
-rw-r--r--actionpack/lib/action_controller/abstract/base.rb6
-rw-r--r--actionpack/lib/action_controller/abstract/logger.rb4
-rw-r--r--actionpack/lib/action_controller/new_base/http.rb5
-rw-r--r--actionpack/lib/action_controller/routing.rb5
6 files changed, 50 insertions, 21 deletions
diff --git a/actionpack/examples/minimal.rb b/actionpack/examples/minimal.rb
new file mode 100644
index 0000000000..84a8499daf
--- /dev/null
+++ b/actionpack/examples/minimal.rb
@@ -0,0 +1,34 @@
+$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"
+require 'action_controller'
+require 'action_controller/new_base' if ENV['NEW']
+require 'benchmark'
+
+class BaseController < ActionController::Base
+ def index
+ render :text => ''
+ end
+end
+
+n = (ENV['N'] || 10000).to_i
+input = StringIO.new('')
+
+def call_index(controller, input, n)
+ n.times do
+ controller.action(:index).call({ 'rack.input' => input })
+ end
+
+ puts controller.name
+ status, headers, body = controller.action(:index).call({ 'rack.input' => input })
+
+ puts status
+ puts headers.to_yaml
+ puts '---'
+ body.each do |part|
+ puts part
+ end
+ puts '---'
+end
+
+elapsed = Benchmark.realtime { call_index BaseController, input, n }
+
+puts "%dms elapsed, %d requests/sec" % [1000 * elapsed, n / elapsed]
diff --git a/actionpack/examples/simple.rb b/actionpack/examples/simple.rb
deleted file mode 100644
index 4ecb824688..0000000000
--- a/actionpack/examples/simple.rb
+++ /dev/null
@@ -1,17 +0,0 @@
-$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"
-require 'action_controller'
-
-class PeopleController < ActionController::Base
- def index
- head :ok
- end
-end
-
-status, headers, body = PeopleController.action(:index).call({ 'rack.input' => StringIO.new('') })
-
-puts status
-puts headers.to_yaml
-puts '---'
-body.each do |part|
- puts part
-end
diff --git a/actionpack/lib/action_controller/abstract/base.rb b/actionpack/lib/action_controller/abstract/base.rb
index c9e1081b23..4b8d953643 100644
--- a/actionpack/lib/action_controller/abstract/base.rb
+++ b/actionpack/lib/action_controller/abstract/base.rb
@@ -1,3 +1,5 @@
+require 'active_support/core_ext/module/attr_internal'
+
module AbstractController
class Error < StandardError; end
@@ -89,7 +91,7 @@ module AbstractController
# you must handle it by also overriding process_action and
# handling the case.
def respond_to_action?(action_name)
- action_methods.include?(action_name) || respond_to?(:action_missing, true)
+ action_methods.include?(action_name.to_s) || respond_to?(:action_missing, true)
end
end
-end \ No newline at end of file
+end
diff --git a/actionpack/lib/action_controller/abstract/logger.rb b/actionpack/lib/action_controller/abstract/logger.rb
index 5fb78f1755..b154be754b 100644
--- a/actionpack/lib/action_controller/abstract/logger.rb
+++ b/actionpack/lib/action_controller/abstract/logger.rb
@@ -1,3 +1,5 @@
+require 'active_support/core_ext/class/attribute_accessors'
+
module AbstractController
module Logger
extend ActiveSupport::DependencyModule
@@ -6,4 +8,4 @@ module AbstractController
cattr_accessor :logger
end
end
-end \ No newline at end of file
+end
diff --git a/actionpack/lib/action_controller/new_base/http.rb b/actionpack/lib/action_controller/new_base/http.rb
index fb6041a04e..6852eb200a 100644
--- a/actionpack/lib/action_controller/new_base/http.rb
+++ b/actionpack/lib/action_controller/new_base/http.rb
@@ -1,3 +1,6 @@
+require 'action_controller/abstract'
+require 'active_support/core_ext/module/delegation'
+
module ActionController
class Http < AbstractController::Base
abstract!
@@ -57,7 +60,7 @@ module ActionController
def self.action(name)
@actions ||= {}
- @actions[name] ||= proc do |env|
+ @actions[name.to_s] ||= proc do |env|
new.call(name, env)
end
end
diff --git a/actionpack/lib/action_controller/routing.rb b/actionpack/lib/action_controller/routing.rb
index c0eb61340b..7edd379bc0 100644
--- a/actionpack/lib/action_controller/routing.rb
+++ b/actionpack/lib/action_controller/routing.rb
@@ -1,5 +1,10 @@
require 'cgi'
require 'uri'
+require 'set'
+
+require 'active_support/core_ext/module/aliasing'
+require 'active_support/core_ext/module/attribute_accessors'
+
require 'action_controller/routing/optimisations'
require 'action_controller/routing/routing_ext'
require 'action_controller/routing/route'