aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorYehuda Katz <wycats@gmail.com>2009-08-08 12:54:02 -0300
committerYehuda Katz <wycats@gmail.com>2009-08-08 12:54:02 -0300
commitad98827a78d0ee13c5d3b8c5caf2fccfa294277c (patch)
treec66a41b020dbecd209d4f8de2850eefaa06ba793 /actionpack
parentefcfce50c417975ee038a107755a1542a690d39b (diff)
parent016ed9b4298d187182d05340baddbe98f4eb8fb5 (diff)
downloadrails-ad98827a78d0ee13c5d3b8c5caf2fccfa294277c.tar.gz
rails-ad98827a78d0ee13c5d3b8c5caf2fccfa294277c.tar.bz2
rails-ad98827a78d0ee13c5d3b8c5caf2fccfa294277c.zip
Merge commit 'jose/responder'
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_controller.rb2
-rw-r--r--actionpack/lib/action_controller/metal/mime_responds.rb26
-rw-r--r--actionpack/lib/action_controller/metal/responder.rb (renamed from actionpack/lib/action_controller/metal/renderer.rb)24
-rw-r--r--actionpack/test/controller/mime_responds_test.rb10
4 files changed, 31 insertions, 31 deletions
diff --git a/actionpack/lib/action_controller.rb b/actionpack/lib/action_controller.rb
index 8343a87936..37ff618edd 100644
--- a/actionpack/lib/action_controller.rb
+++ b/actionpack/lib/action_controller.rb
@@ -7,10 +7,10 @@ module ActionController
autoload :RackConvenience, "action_controller/metal/rack_convenience"
autoload :Rails2Compatibility, "action_controller/metal/compatibility"
autoload :Redirector, "action_controller/metal/redirector"
- autoload :Renderer, "action_controller/metal/renderer"
autoload :RenderingController, "action_controller/metal/rendering_controller"
autoload :RenderOptions, "action_controller/metal/render_options"
autoload :Rescue, "action_controller/metal/rescuable"
+ autoload :Responder, "action_controller/metal/responder"
autoload :Testing, "action_controller/metal/testing"
autoload :UrlFor, "action_controller/metal/url_for"
autoload :Session, "action_controller/metal/session"
diff --git a/actionpack/lib/action_controller/metal/mime_responds.rb b/actionpack/lib/action_controller/metal/mime_responds.rb
index d823dd424a..c8d042acb5 100644
--- a/actionpack/lib/action_controller/metal/mime_responds.rb
+++ b/actionpack/lib/action_controller/metal/mime_responds.rb
@@ -179,15 +179,15 @@ module ActionController #:nodoc:
def respond_to(*mimes, &block)
raise ArgumentError, "respond_to takes either types or a block, never both" if mimes.any? && block_given?
- responder = Responder.new
+ collector = Collector.new
mimes = collect_mimes_from_class_level if mimes.empty?
- mimes.each { |mime| responder.send(mime) }
- block.call(responder) if block_given?
+ mimes.each { |mime| collector.send(mime) }
+ block.call(collector) if block_given?
- if format = request.negotiate_mime(responder.order)
+ if format = request.negotiate_mime(collector.order)
self.formats = [format.to_sym]
- if response = responder.response_for(format)
+ if response = collector.response_for(format)
response.call
else
default_render
@@ -197,10 +197,10 @@ module ActionController #:nodoc:
end
end
- # respond_with wraps a resource around a renderer for default representation.
+ # respond_with wraps a resource around a responder for default representation.
# First it invokes respond_to, if a response cannot be found (ie. no block
# for the request was given and template was not available), it instantiates
- # an ActionController::Renderer with the controller and resource.
+ # an ActionController::Responder with the controller and resource.
#
# ==== Example
#
@@ -221,19 +221,19 @@ module ActionController #:nodoc:
# end
# end
#
- # All options given to respond_with are sent to the underlying renderer,
- # except for the option :renderer itself. Since the renderer interface
+ # All options given to respond_with are sent to the underlying responder,
+ # except for the option :responder itself. Since the responder interface
# is quite simple (it just needs to respond to call), you can even give
# a proc to it.
#
def respond_with(resource, options={}, &block)
respond_to(&block)
rescue ActionView::MissingTemplate
- (options.delete(:renderer) || renderer).call(self, resource, options)
+ (options.delete(:responder) || responder).call(self, resource, options)
end
- def renderer
- ActionController::Renderer
+ def responder
+ ActionController::Responder
end
protected
@@ -257,7 +257,7 @@ module ActionController #:nodoc:
end
end
- class Responder #:nodoc:
+ class Collector #:nodoc:
attr_accessor :order
def initialize
diff --git a/actionpack/lib/action_controller/metal/renderer.rb b/actionpack/lib/action_controller/metal/responder.rb
index 39ab2407aa..9ed99ca623 100644
--- a/actionpack/lib/action_controller/metal/renderer.rb
+++ b/actionpack/lib/action_controller/metal/responder.rb
@@ -1,6 +1,6 @@
module ActionController #:nodoc:
- # Renderer is responsible to expose a resource for different mime requests,
- # usually depending on the HTTP verb. The renderer is triggered when
+ # Responder is responsible to expose a resource for different mime requests,
+ # usually depending on the HTTP verb. The responder is triggered when
# respond_with is called. The simplest case to study is a GET request:
#
# class PeopleController < ApplicationController
@@ -16,17 +16,17 @@ module ActionController #:nodoc:
#
# 1) respond_with searches for a template at people/index.xml;
#
- # 2) if the template is not available, it will create a renderer, passing
+ # 2) if the template is not available, it will create a responder, passing
# the controller and the resource and invoke :to_xml on it;
#
- # 3) if the renderer does not respond_to :to_xml, call to_format on it.
+ # 3) if the responder does not respond_to :to_xml, call to_format on it.
#
# === Builtin HTTP verb semantics
#
- # Rails default renderer holds semantics for each HTTP verb. Depending on the
+ # Rails default responder holds semantics for each HTTP verb. Depending on the
# content type, verb and the resource status, it will behave differently.
#
- # Using Rails default renderer, a POST request for creating an object could
+ # Using Rails default responder, a POST request for creating an object could
# be written as:
#
# def create
@@ -67,7 +67,7 @@ module ActionController #:nodoc:
# respond_with([@project, @task])
# end
#
- # Giving an array of resources, you ensure that the renderer will redirect to
+ # Giving an array of resources, you ensure that the responder will redirect to
# project_task_url instead of task_url.
#
# Namespaced and singleton resources requires a symbol to be given, as in
@@ -78,7 +78,7 @@ module ActionController #:nodoc:
#
# Check polymorphic_url documentation for more examples.
#
- class Renderer
+ class Responder
attr_reader :controller, :request, :format, :resource, :resource_location, :options
def initialize(controller, resource, options={})
@@ -96,13 +96,13 @@ module ActionController #:nodoc:
# Undefine :to_json since it's defined on Object
undef_method :to_json
- # Initializes a new renderer an invoke the proper format. If the format is
+ # Initializes a new responder an invoke the proper format. If the format is
# not defined, call to_format.
#
def self.call(*args)
- renderer = new(*args)
- method = :"to_#{renderer.format}"
- renderer.respond_to?(method) ? renderer.send(method) : renderer.to_format
+ responder = new(*args)
+ method = :"to_#{responder.format}"
+ responder.respond_to?(method) ? responder.send(method) : responder.to_format
end
# HTML format does not render the resource, it always attempt to render a
diff --git a/actionpack/test/controller/mime_responds_test.rb b/actionpack/test/controller/mime_responds_test.rb
index 00ad90ff68..8319b5c573 100644
--- a/actionpack/test/controller/mime_responds_test.rb
+++ b/actionpack/test/controller/mime_responds_test.rb
@@ -505,9 +505,9 @@ class RespondWithController < ActionController::Base
respond_with(Customer.new("david", 13), :location => "http://test.host/", :status => :created)
end
- def using_resource_with_renderer
- renderer = proc { |c, r, o| c.render :text => "Resource name is #{r.name}" }
- respond_with(Customer.new("david", 13), :renderer => renderer)
+ def using_resource_with_responder
+ responder = proc { |c, r, o| c.render :text => "Resource name is #{r.name}" }
+ respond_with(Customer.new("david", 13), :responder => responder)
end
protected
@@ -743,8 +743,8 @@ class RespondWithControllerTest < ActionController::TestCase
assert_equal 201, @response.status
end
- def test_using_resource_with_renderer
- get :using_resource_with_renderer
+ def test_using_resource_with_responder
+ get :using_resource_with_responder
assert_equal "Resource name is david", @response.body
end