Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Renamed ActionController::Renderer to ActionController::Responder and…

… ActionController::MimeResponds::Responder to ActionController::MimeResponds::Collector.
  • Loading branch information...
commit 6e0ac748e41e8de8111095f7188c75f673779f93 1 parent 0fbeaa9
José Valim josevalim authored
2  actionpack/lib/action_controller.rb
View
@@ -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"
26 actionpack/lib/action_controller/metal/mime_responds.rb
View
@@ -179,15 +179,15 @@ def clear_respond_to
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 @@ def respond_to(*mimes, &block)
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 @@ def respond_to(*mimes, &block)
# 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 @@ def collect_mimes_from_class_level #:nodoc:
end
end
- class Responder #:nodoc:
+ class Collector #:nodoc:
attr_accessor :order
def initialize
24 actionpack/lib/action_controller/metal/renderer.rb → actionpack/lib/action_controller/metal/responder.rb
View
@@ -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 @@ def initialize(controller, resource, options={})
# 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
10 actionpack/test/controller/mime_responds_test.rb
View
@@ -505,9 +505,9 @@ def using_resource_with_status_and_location
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 @@ def test_using_resource_with_status_and_location
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
Please sign in to comment.
Something went wrong with that request. Please try again.