Skip to content

Commit fa8e17b

Browse files
committed
Merge remote branch 'docrails/master'
2 parents d2f55e7 + ee7507b commit fa8e17b

File tree

16 files changed

+268
-103
lines changed

16 files changed

+268
-103
lines changed

README.rdoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,12 +48,12 @@ more separate. Each of these packages can be used independently outside of
4848

4949
"Welcome aboard: You're riding Ruby on Rails!"
5050

51-
5. Follow the guidelines to start developing your application. You can find
52-
the following resources handy:
51+
5. Follow the guidelines to start developing your application. You can find the following resources handy:
5352

5453
* The README file created within your application.
5554
* The {Getting Started Guide}[http://guides.rubyonrails.org/getting_started.html].
5655
* The {Ruby on Rails Tutorial Book}[http://railstutorial.org/book].
56+
* The {API documentation}[http://api.rubyonrails.org].
5757

5858

5959
== Contributing

actionpack/lib/abstract_controller/base.rb

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ module AbstractController
66
class Error < StandardError; end
77
class ActionNotFound < StandardError; end
88

9+
# <tt>AbstractController::Base</tt> is a low-level API. Nobody should be
10+
# using it directly, and subclasses (like ActionController::Base) are
11+
# expected to provide their own +render+ method, since rendering means
12+
# different things depending on the context.
913
class Base
1014
attr_internal :response_body
1115
attr_internal :action_name
@@ -36,13 +40,12 @@ def internal_methods
3640
controller.public_instance_methods(true)
3741
end
3842

39-
# The list of hidden actions to an empty Array. Defaults to an
40-
# empty Array. This can be modified by other modules or subclasses
43+
# The list of hidden actions to an empty array. Defaults to an
44+
# empty array. This can be modified by other modules or subclasses
4145
# to specify particular actions as hidden.
4246
#
4347
# ==== Returns
44-
# Array[String]:: An array of method names that should not be
45-
# considered actions.
48+
# * <tt>array</tt> - An array of method names that should not be considered actions.
4649
def hidden_actions
4750
[]
4851
end
@@ -54,8 +57,7 @@ def hidden_actions
5457
# itself. Finally, #hidden_actions are removed.
5558
#
5659
# ==== Returns
57-
# Array[String]:: A list of all methods that should be considered
58-
# actions.
60+
# * <tt>array</tt> - A list of all methods that should be considered actions.
5961
def action_methods
6062
@action_methods ||= begin
6163
# All public instance methods of this class, including ancestors
@@ -84,7 +86,7 @@ def clear_action_methods!
8486
# controller_name.
8587
#
8688
# ==== Returns
87-
# String
89+
# * <tt>string</tt>
8890
def controller_path
8991
@controller_path ||= name.sub(/Controller$/, '').underscore unless anonymous?
9092
end
@@ -104,7 +106,7 @@ def method_added(name)
104106
# ActionNotFound error is raised.
105107
#
106108
# ==== Returns
107-
# self
109+
# * <tt>self</tt>
108110
def process(action, *args)
109111
@_action_name = action_name = action.to_s
110112

@@ -133,10 +135,10 @@ def action_methods
133135
# can be considered an action.
134136
#
135137
# ==== Parameters
136-
# name<String>:: The name of an action to be tested
138+
# * <tt>name</tt> - The name of an action to be tested
137139
#
138140
# ==== Returns
139-
# TrueClass, FalseClass
141+
# * <tt>TrueClass</tt>, <tt>FalseClass</tt>
140142
def action_method?(name)
141143
self.class.action_methods.include?(name)
142144
end
@@ -180,11 +182,11 @@ def _handle_action_missing
180182
# returns nil, an ActionNotFound exception will be raised.
181183
#
182184
# ==== Parameters
183-
# action_name<String>:: An action name to find a method name for
185+
# * <tt>action_name</tt> - An action name to find a method name for
184186
#
185187
# ==== Returns
186-
# String:: The name of the method that handles the action
187-
# nil:: No method name could be found. Raise ActionNotFound.
188+
# * <tt>string</tt> - The name of the method that handles the action
189+
# * <tt>nil</tt> - No method name could be found. Raise ActionNotFound.
188190
def method_for_action(action_name)
189191
if action_method?(action_name) then action_name
190192
elsif respond_to?(:action_missing, true) then "_handle_action_missing"

actionpack/lib/abstract_controller/callbacks.rb

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -28,9 +28,8 @@ module ClassMethods
2828
# a Rails process.
2929
#
3030
# ==== Options
31-
# :only<#to_s>:: The callback should be run only for this action
32-
# :except<#to_s>:: The callback should be run for all actions
33-
# except this action
31+
# * <tt>only</tt> - The callback should be run only for this action
32+
# * <tt>except<tt> - The callback should be run for all actions except this action
3433
def _normalize_callback_options(options)
3534
if only = options[:only]
3635
only = Array(only).map {|o| "action_name == '#{o}'"}.join(" || ")
@@ -45,7 +44,7 @@ def _normalize_callback_options(options)
4544
# Skip before, after, and around filters matching any of the names
4645
#
4746
# ==== Parameters
48-
# *names<Object>:: A list of valid names that could be used for
47+
# * <tt>names</tt> - A list of valid names that could be used for
4948
# callbacks. Note that skipping uses Ruby equality, so it's
5049
# impossible to skip a callback defined using an anonymous proc
5150
# using #skip_filter
@@ -60,13 +59,13 @@ def skip_filter(*names, &blk)
6059
# the normalization across several methods that use it.
6160
#
6261
# ==== Parameters
63-
# callbacks<Array[*Object, Hash]>:: A list of callbacks, with an optional
62+
# * <tt>callbacks</tt> - An array of callbacks, with an optional
6463
# options hash as the last parameter.
65-
# block<Proc>:: A proc that should be added to the callbacks.
64+
# * <tt>block</tt> - A proc that should be added to the callbacks.
6665
#
6766
# ==== Block Parameters
68-
# name<Symbol>:: The callback to be added
69-
# options<Hash>:: A list of options to be used when adding the callback
67+
# * <tt>name</tt> - The callback to be added
68+
# * <tt>options</tt> - A hash of options to be used when adding the callback
7069
def _insert_callbacks(callbacks, block)
7170
options = callbacks.last.is_a?(Hash) ? callbacks.pop : {}
7271
_normalize_callback_options(options)
@@ -82,27 +81,27 @@ def _insert_callbacks(callbacks, block)
8281
class_eval <<-RUBY_EVAL, __FILE__, __LINE__ + 1
8382
# Append a before, after or around filter. See _insert_callbacks
8483
# for details on the allowed parameters.
85-
def #{filter}_filter(*names, &blk)
86-
_insert_callbacks(names, blk) do |name, options|
87-
set_callback(:process_action, :#{filter}, name, options)
88-
end
89-
end
84+
def #{filter}_filter(*names, &blk) # def before_filter(*names, &blk)
85+
_insert_callbacks(names, blk) do |name, options| # _insert_callbacks(names, blk) do |name, options}
86+
set_callback(:process_action, :#{filter}, name, options) # set_callback(:process_action, :before_filter, name, options)
87+
end # end
88+
end # end
9089
9190
# Prepend a before, after or around filter. See _insert_callbacks
9291
# for details on the allowed parameters.
93-
def prepend_#{filter}_filter(*names, &blk)
94-
_insert_callbacks(names, blk) do |name, options|
95-
set_callback(:process_action, :#{filter}, name, options.merge(:prepend => true))
96-
end
97-
end
92+
def prepend_#{filter}_filter(*names, &blk) # def prepend_before_filter(*names, &blk)
93+
_insert_callbacks(names, blk) do |name, options| # _insert_callbacks(names, blk) do |name, options|
94+
set_callback(:process_action, :#{filter}, name, options.merge(:prepend => true)) # set_callback(:process_action, :before, name, options.merge(:prepend => true))
95+
end # end
96+
end # end
9897
9998
# Skip a before, after or around filter. See _insert_callbacks
10099
# for details on the allowed parameters.
101-
def skip_#{filter}_filter(*names, &blk)
102-
_insert_callbacks(names, blk) do |name, options|
103-
skip_callback(:process_action, :#{filter}, name, options)
104-
end
105-
end
100+
def skip_#{filter}_filter(*names, &blk) # def skip_before_filter(*names, &blk)
101+
_insert_callbacks(names, blk) do |name, options| # _insert_callbacks(names, blk) do |name, options|
102+
skip_callback(:process_action, :#{filter}, name, options) # skip_callback(:process_action, :before, name, options)
103+
end # end
104+
end # end
106105
107106
# *_filter is the same as append_*_filter
108107
alias_method :append_#{filter}_filter, :#{filter}_filter

actionpack/lib/abstract_controller/helpers.rb

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def inherited(klass)
4040
# <% if logged_in? -%>Welcome, <%= current_user.name %><% end -%>
4141
#
4242
# ==== Parameters
43-
# meths<Array[#to_s]>:: The name of a method on the controller
43+
# * <tt>method[, method]</tt> - A name or names of a method on the controller
4444
# to be made available on the view.
4545
def helper_method(*meths)
4646
meths.flatten.each do |meth|
@@ -55,8 +55,8 @@ def #{meth}(*args, &blk)
5555
# The +helper+ class method can take a series of helper module names, a block, or both.
5656
#
5757
# ==== Parameters
58-
# *args<Array[Module, Symbol, String, :all]>
59-
# block<Block>:: A block defining helper methods
58+
# * <tt>*args</tt> - Module, Symbol, String, :all
59+
# * <tt>block</tt> - A block defining helper methods
6060
#
6161
# ==== Examples
6262
# When the argument is a module it will be included directly in the template class.
@@ -100,7 +100,7 @@ def helper(*args, &block)
100100
# rendered through this controller.
101101
#
102102
# ==== Parameters
103-
# mod<Module>:: The module to include into the current helper module
103+
# * <tt>module</tt> - The module to include into the current helper module
104104
# for the class
105105
def add_template_helper(mod)
106106
_helpers.module_eval { include mod }
@@ -118,10 +118,10 @@ def add_template_helper(mod)
118118
# are returned.
119119
#
120120
# ==== Parameters
121-
# args<Array[String, Symbol, Module]>:: A list of helpers
121+
# * <tt>args</tt> - An array of helpers
122122
#
123123
# ==== Returns
124-
# Array[Module]:: A normalized list of modules for the list of
124+
# * <tt>Array</tt> - A normalized list of modules for the list of
125125
# helpers provided.
126126
def modules_for_helpers(args)
127127
args.flatten.map! do |arg|

actionpack/lib/abstract_controller/layouts.rb

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,13 @@ module AbstractController
114114
#
115115
# class WeblogController < ActionController::Base
116116
# layout proc{ |controller| controller.logged_in? ? "writer_layout" : "reader_layout" }
117+
# end
117118
#
118119
# Of course, the most common way of specifying a layout is still just as a plain template name:
119120
#
120121
# class WeblogController < ActionController::Base
121122
# layout "weblog_standard"
123+
# end
122124
#
123125
# If no directory is specified for the template name, the template will by default be looked for in <tt>app/views/layouts/</tt>.
124126
# Otherwise, it will be looked up relative to the template root.
@@ -183,7 +185,7 @@ module LayoutConditions
183185
# layout.
184186
#
185187
# ==== Returns
186-
# Boolean:: True if the action has a layout, false otherwise.
188+
# * <tt> Boolean</tt> - True if the action has a layout, false otherwise.
187189
def action_has_layout?
188190
return unless super
189191

@@ -209,11 +211,11 @@ def action_has_layout?
209211
# true:: raise an ArgumentError
210212
#
211213
# ==== Parameters
212-
# layout<String, Symbol, false)>:: The layout to use.
214+
# * <tt>String, Symbol, false</tt> - The layout to use.
213215
#
214216
# ==== Options (conditions)
215-
# :only<#to_s, Array[#to_s]>:: A list of actions to apply this layout to.
216-
# :except<#to_s, Array[#to_s]>:: Apply this layout to all actions but this one
217+
# * :only - A list of actions to apply this layout to.
218+
# * :except - Apply this layout to all actions but this one.
217219
def layout(layout, conditions = {})
218220
include LayoutConditions unless conditions.empty?
219221

@@ -228,7 +230,7 @@ def layout(layout, conditions = {})
228230
# value of this method.
229231
#
230232
# ==== Returns
231-
# String:: A template name
233+
# * <tt>String</tt> - A template name
232234
def _implied_layout_name
233235
controller_path
234236
end
@@ -313,8 +315,8 @@ def _layout; end
313315
# the name type.
314316
#
315317
# ==== Parameters
316-
# name<String|TrueClass|FalseClass|Symbol>:: The name of the template
317-
# details<Hash{Symbol => Object}>:: A list of details to restrict
318+
# * <tt>name</tt> - The name of the template
319+
# * <tt>details</tt> - A list of details to restrict
318320
# the lookup to. By default, layout lookup is limited to the
319321
# formats specified for the current request.
320322
def _layout_for_option(name)
@@ -333,14 +335,14 @@ def _layout_for_option(name)
333335
# Optionally raises an exception if the layout could not be found.
334336
#
335337
# ==== Parameters
336-
# details<Hash>:: A list of details to restrict the search by. This
338+
# * <tt>details</tt> - A list of details to restrict the search by. This
337339
# might include details like the format or locale of the template.
338-
# require_layout<Boolean>:: If this is true, raise an ArgumentError
340+
# * <tt>require_logout</tt> - If this is true, raise an ArgumentError
339341
# with details about the fact that the exception could not be
340342
# found (defaults to false)
341343
#
342344
# ==== Returns
343-
# Template:: The template object for the default layout (or nil)
345+
# * <tt>template</tt> - The template object for the default layout (or nil)
344346
def _default_layout(require_layout = false)
345347
begin
346348
layout_name = _layout if action_has_layout?

actionpack/lib/abstract_controller/view_paths.rb

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,19 +34,19 @@ module ClassMethods
3434
# Append a path to the list of view paths for this controller.
3535
#
3636
# ==== Parameters
37-
# path<String, ViewPath>:: If a String is provided, it gets converted into
38-
# the default view path. You may also provide a custom view path
39-
# (see ActionView::ViewPathSet for more information)
37+
# * <tt>path</tt> - If a String is provided, it gets converted into
38+
# the default view path. You may also provide a custom view path
39+
# (see ActionView::ViewPathSet for more information)
4040
def append_view_path(path)
4141
self.view_paths = view_paths.dup + Array(path)
4242
end
4343

4444
# Prepend a path to the list of view paths for this controller.
4545
#
4646
# ==== Parameters
47-
# path<String, ViewPath>:: If a String is provided, it gets converted into
48-
# the default view path. You may also provide a custom view path
49-
# (see ActionView::ViewPathSet for more information)
47+
# * <tt>path</tt> - If a String is provided, it gets converted into
48+
# the default view path. You may also provide a custom view path
49+
# (see ActionView::ViewPathSet for more information)
5050
def prepend_view_path(path)
5151
self.view_paths = Array(path) + view_paths.dup
5252
end
@@ -59,7 +59,7 @@ def view_paths
5959
# Set the view paths.
6060
#
6161
# ==== Parameters
62-
# paths<ViewPathSet, Object>:: If a ViewPathSet is provided, use that;
62+
# * <tt>paths</tt> - If a ViewPathSet is provided, use that;
6363
# otherwise, process the parameter into a ViewPathSet.
6464
def view_paths=(paths)
6565
self._view_paths = ActionView::Base.process_view_paths(paths)

0 commit comments

Comments
 (0)