Skip to content

Commit 8950070

Browse files
authored
Merge pull request rails#50063 from skipkayhil/hm-doc-metal
Add documentation for delegated methods on Metal
2 parents 99fd4c0 + eb60e20 commit 8950070

File tree

2 files changed

+45
-8
lines changed

2 files changed

+45
-8
lines changed

actionpack/lib/action_controller/metal.rb

Lines changed: 32 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,14 @@ def build_middleware(klass, args, block)
8181
#
8282
# get 'hello', to: HelloController.action(:index)
8383
#
84-
# The `action` method returns a valid Rack application for the Rails router to
84+
# The ::action method returns a valid Rack application for the Rails router to
8585
# dispatch to.
8686
#
8787
# ## Rendering Helpers
8888
#
89-
# `ActionController::Metal` by default provides no utilities for rendering
90-
# views, partials, or other responses aside from explicitly calling of
91-
# `response_body=`, `content_type=`, and `status=`. To add the render helpers
89+
# By default, `ActionController::Metal` provides no utilities for rendering
90+
# views, partials, or other responses aside from some low-level setters such
91+
# as #response_body=, #content_type=, and #status=. To add the render helpers
9292
# you're used to having in a normal controller, you can do the following:
9393
#
9494
# class HelloController < ActionController::Metal
@@ -179,8 +179,33 @@ def controller_name
179179
# Delegates to ActionDispatch::Response#headers.
180180
delegate :headers, to: "@_response"
181181

182-
delegate :status=, :location=, :content_type=,
183-
:status, :location, :content_type, :media_type, to: "@_response"
182+
##
183+
# Delegates to ActionDispatch::Response#status=
184+
delegate :status=, to: "@_response"
185+
186+
##
187+
# Delegates to ActionDispatch::Response#location=
188+
delegate :location=, to: "@_response"
189+
190+
##
191+
# Delegates to ActionDispatch::Response#content_type=
192+
delegate :content_type=, to: "@_response"
193+
194+
##
195+
# Delegates to ActionDispatch::Response#status
196+
delegate :status, to: "@_response"
197+
198+
##
199+
# Delegates to ActionDispatch::Response#location
200+
delegate :location, to: "@_response"
201+
202+
##
203+
# Delegates to ActionDispatch::Response#content_type
204+
delegate :content_type, to: "@_response"
205+
206+
##
207+
# Delegates to ActionDispatch::Response#media_type
208+
delegate :media_type, to: "@_response"
184209

185210
def initialize
186211
@_request = nil
@@ -201,7 +226,7 @@ def params=(val)
201226

202227
alias :response_code :status # :nodoc:
203228

204-
# Basic url_for that can be overridden for more robust functionality.
229+
# Basic `url_for` that can be overridden for more robust functionality.
205230
def url_for(string)
206231
string
207232
end

actionpack/lib/action_dispatch/http/response.rb

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,18 @@ def sending?; synchronize { @sending }; end
231231
def committed?; synchronize { @committed }; end
232232
def sent?; synchronize { @sent }; end
233233

234+
##
235+
# :method: location
236+
#
237+
# Location of the response.
238+
239+
##
240+
# :method: location=
241+
#
242+
# :call-seq: location=(location)
243+
#
244+
# Sets the location of the response
245+
234246
# Sets the HTTP status code.
235247
def status=(status)
236248
@status = Rack::Utils.status_code(status)
@@ -241,7 +253,7 @@ def status=(status)
241253
#
242254
# response.content_type = "text/plain"
243255
#
244-
# If a character set has been defined for this response (see charset=) then the
256+
# If a character set has been defined for this response (see #charset=) then the
245257
# character set information will also be included in the content type
246258
# information.
247259
def content_type=(content_type)

0 commit comments

Comments
 (0)