Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Revert "Remove blank trailing comments"

This reverts commit fa6d921.

Reason: Not a fan of such massive changes. We usually close such changes
if made to Rails master as a pull request. Following the same principle
here and reverting.

[ci skip]
  • Loading branch information...
commit 1ad0b378cc081937c117577ab628f2160fcc448d 1 parent 2642c29
@vijaydev vijaydev authored
Showing with 192 additions and 0 deletions.
  1. +1 −0  Rakefile
  2. +1 −0  actionmailer/lib/action_mailer/delivery_methods.rb
  3. +1 −0  actionmailer/lib/rails/generators/mailer/templates/mailer.rb
  4. +1 −0  actionpack/lib/abstract_controller/helpers.rb
  5. +1 −0  actionpack/lib/action_controller/base.rb
  6. +2 −0  actionpack/lib/action_controller/metal.rb
  7. +1 −0  actionpack/lib/action_controller/metal/helpers.rb
  8. +1 −0  actionpack/lib/action_controller/metal/mime_responds.rb
  9. +10 −0 actionpack/lib/action_controller/metal/responder.rb
  10. +1 −0  actionpack/lib/action_controller/metal/streaming.rb
  11. +2 −0  actionpack/lib/action_dispatch/http/mime_negotiation.rb
  12. +1 −0  actionpack/lib/action_dispatch/middleware/reloader.rb
  13. +1 −0  actionpack/lib/action_dispatch/routing.rb
  14. +1 −0  actionpack/lib/action_dispatch/routing/mapper.rb
  15. +2 −0  actionpack/lib/action_dispatch/routing/polymorphic_routes.rb
  16. +1 −0  actionpack/lib/action_dispatch/routing/redirection.rb
  17. +1 −0  actionpack/lib/action_dispatch/routing/route_set.rb
  18. +1 −0  actionpack/lib/action_dispatch/routing/url_for.rb
  19. +1 −0  actionpack/lib/action_dispatch/testing/assertions/routing.rb
  20. +1 −0  actionpack/lib/action_view/helpers/asset_tag_helpers/stylesheet_tag_helpers.rb
  21. +1 −0  actionpack/lib/action_view/helpers/capture_helper.rb
  22. +11 −0 actionpack/lib/action_view/helpers/form_helper.rb
  23. +3 −0  actionpack/lib/action_view/helpers/form_options_helper.rb
  24. +3 −0  actionpack/lib/action_view/helpers/form_tag_helper.rb
  25. +1 −0  actionpack/lib/action_view/helpers/number_helper.rb
  26. +1 −0  actionpack/lib/action_view/helpers/output_safety_helper.rb
  27. +2 −0  actionpack/lib/action_view/helpers/record_tag_helper.rb
  28. +1 −0  actionpack/lib/action_view/helpers/rendering_helper.rb
  29. +12 −0 actionpack/lib/action_view/helpers/sanitize_helper.rb
  30. +1 −0  actionpack/lib/action_view/helpers/tags/select.rb
  31. +1 −0  actionpack/lib/action_view/helpers/url_helper.rb
  32. +1 −0  actionpack/lib/action_view/template/resolver.rb
  33. +1 −0  activemodel/lib/active_model/attribute_methods.rb
  34. +1 −0  activemodel/lib/active_model/callbacks.rb
  35. +1 −0  activemodel/lib/active_model/conversion.rb
  36. +1 −0  activemodel/lib/active_model/errors.rb
  37. +2 −0  activemodel/lib/active_model/lint.rb
  38. +2 −0  activemodel/lib/active_model/mass_assignment_security.rb
  39. +2 −0  activemodel/lib/active_model/observing.rb
  40. +1 −0  activemodel/lib/active_model/serialization.rb
  41. +2 −0  activemodel/lib/active_model/validations.rb
  42. +1 −0  activemodel/lib/active_model/validations/validates.rb
  43. +2 −0  activemodel/lib/active_model/validator.rb
  44. +1 −0  activemodel/test/cases/validations/i18n_validation_test.rb
  45. +2 −0  activerecord/lib/active_record/aggregations.rb
  46. +1 −0  activerecord/lib/active_record/associations/association.rb
  47. +1 −0  activerecord/lib/active_record/callbacks.rb
  48. +1 −0  activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
  49. +1 −0  activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
  50. +1 −0  activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
  51. +1 −0  activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
  52. +1 −0  activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb
  53. +1 −0  activerecord/lib/active_record/locking/optimistic.rb
  54. +1 −0  activerecord/lib/active_record/model.rb
  55. +1 −0  activerecord/lib/active_record/observer.rb
  56. +1 −0  activerecord/lib/active_record/persistence.rb
  57. +6 −0 activerecord/lib/active_record/reflection.rb
  58. +1 −0  activerecord/lib/active_record/relation/calculations.rb
  59. +1 −0  activerecord/lib/active_record/relation/finder_methods.rb
  60. +3 −0  activerecord/lib/active_record/relation/query_methods.rb
  61. +3 −0  activerecord/lib/active_record/relation/spawn_methods.rb
  62. +1 −0  activerecord/lib/active_record/validations/uniqueness.rb
  63. +1 −0  activerecord/test/cases/attribute_methods_test.rb
  64. +1 −0  activerecord/test/cases/validations/i18n_validation_test.rb
  65. +1 −0  activerecord/test/models/subject.rb
  66. +1 −0  activesupport/lib/active_support/benchmarkable.rb
  67. +1 −0  activesupport/lib/active_support/callbacks.rb
  68. +1 −0  activesupport/lib/active_support/concern.rb
  69. +2 −0  activesupport/lib/active_support/configurable.rb
  70. +1 −0  activesupport/lib/active_support/core_ext/array/conversions.rb
  71. +1 −0  activesupport/lib/active_support/core_ext/array/uniq_by.rb
  72. +2 −0  activesupport/lib/active_support/core_ext/enumerable.rb
  73. +1 −0  activesupport/lib/active_support/core_ext/hash/except.rb
  74. +2 −0  activesupport/lib/active_support/core_ext/hash/indifferent_access.rb
  75. +2 −0  activesupport/lib/active_support/core_ext/integer/inflections.rb
  76. +2 −0  activesupport/lib/active_support/core_ext/kernel/reporting.rb
  77. +1 −0  activesupport/lib/active_support/core_ext/module/anonymous.rb
  78. +1 −0  activesupport/lib/active_support/core_ext/module/delegation.rb
  79. +2 −0  activesupport/lib/active_support/core_ext/module/introspection.rb
  80. +7 −0 activesupport/lib/active_support/core_ext/object/blank.rb
  81. +5 −0 activesupport/lib/active_support/core_ext/object/duplicable.rb
  82. +1 −0  activesupport/lib/active_support/core_ext/object/with_options.rb
  83. +1 −0  activesupport/lib/active_support/core_ext/string/inflections.rb
  84. +1 −0  activesupport/lib/active_support/core_ext/string/output_safety.rb
  85. +1 −0  activesupport/lib/active_support/file_update_checker.rb
  86. +4 −0 activesupport/lib/active_support/hash_with_indifferent_access.rb
  87. +1 −0  activesupport/lib/active_support/inflector/methods.rb
  88. +1 −0  activesupport/lib/active_support/lazy_load_hooks.rb
  89. +1 −0  activesupport/lib/active_support/log_subscriber.rb
  90. +2 −0  activesupport/lib/active_support/log_subscriber/test_helper.rb
  91. +1 −0  activesupport/lib/active_support/message_encryptor.rb
  92. +1 −0  activesupport/lib/active_support/notifications.rb
  93. +1 −0  activesupport/lib/active_support/ordered_options.rb
  94. +1 −0  activesupport/lib/active_support/string_inquirer.rb
  95. +2 −0  activesupport/lib/active_support/time_with_zone.rb
  96. +1 −0  railties/lib/rails/application.rb
  97. +1 −0  railties/lib/rails/configuration.rb
  98. +1 −0  railties/lib/rails/engine/configuration.rb
  99. +1 −0  railties/lib/rails/generators/active_model.rb
  100. +1 −0  railties/lib/rails/generators/base.rb
  101. +1 −0  railties/lib/rails/generators/named_base.rb
  102. +2 −0  railties/lib/rails/generators/resource_helpers.rb
  103. +13 −0 railties/lib/rails/generators/test_case.rb
  104. +1 −0  railties/lib/rails/railtie.rb
  105. +1 −0  railties/test/generators/shared_generator_tests.rb
View
1  Rakefile
@@ -179,6 +179,7 @@ end
# We publish a new version by tagging, and pushing a tag does not trigger
# that webhook. Stable docs would be updated by any subsequent regular
# push, but if you want that to happen right away just run this.
+#
desc 'Publishes docs, run this AFTER a new stable tag has been pushed'
task :publish_docs do
Net::HTTP.new('api.rubyonrails.org', 8080).start do |http|
View
1  actionmailer/lib/action_mailer/delivery_methods.rb
@@ -50,6 +50,7 @@ module ClassMethods
# add_delivery_method :sendmail, Mail::Sendmail,
# :location => '/usr/sbin/sendmail',
# :arguments => '-i -t'
+ #
def add_delivery_method(symbol, klass, default_options={})
class_attribute(:"#{symbol}_settings") unless respond_to?(:"#{symbol}_settings")
send(:"#{symbol}_settings=", default_options)
View
1  actionmailer/lib/rails/generators/mailer/templates/mailer.rb
@@ -7,6 +7,7 @@ class <%= class_name %> < ActionMailer::Base
# with the following lookup:
#
# en.<%= file_path.tr("/",".") %>.<%= action %>.subject
+ #
def <%= action %>
@greeting = "Hi"
View
1  actionpack/lib/abstract_controller/helpers.rb
@@ -90,6 +90,7 @@ def #{meth}(*args, &blk) # def current_user(*args,
# +symbols+, +strings+, +modules+ and blocks.
#
# helper(:three, BlindHelper) { def mice() 'mice' end }
+ #
def helper(*args, &block)
modules_for_helpers(args).each do |mod|
add_template_helper(mod)
View
1  actionpack/lib/action_controller/base.rb
@@ -167,6 +167,7 @@ module ActionController
# redirect_to(:action => "elsewhere") and return if monkeys.nil?
# render :action => "overthere" # won't be called if monkeys is nil
# end
+ #
class Base < Metal
abstract!
View
2  actionpack/lib/action_controller/metal.rb
@@ -9,6 +9,7 @@ module ActionController
# class PostsController < ApplicationController
# use AuthenticationMiddleware, :except => [:index, :show]
# end
+ #
class MiddlewareStack < ActionDispatch::MiddlewareStack #:nodoc:
class Middleware < ActionDispatch::MiddlewareStack::Middleware #:nodoc:
def initialize(klass, *args, &block)
@@ -96,6 +97,7 @@ def build(action, app=nil, &block)
#
# You can refer to the modules included in <tt>ActionController::Base</tt> to see
# other features you can bring into your metal controller.
+ #
class Metal < AbstractController::Base
abstract!
View
1  actionpack/lib/action_controller/metal/helpers.rb
@@ -47,6 +47,7 @@ module ActionController
#
# 23 Aug 11:30 | Carolina Railhawks Soccer Match
# N/A | Carolina Railhaws Training Workshop
+ #
module Helpers
extend ActiveSupport::Concern
View
1  actionpack/lib/action_controller/metal/mime_responds.rb
@@ -52,6 +52,7 @@ def respond_to(*mimes)
end
# Clear all mime types in <tt>respond_to</tt>.
+ #
def clear_respond_to
self.mimes_for_respond_to = Hash.new.freeze
end
View
10 actionpack/lib/action_controller/metal/responder.rb
@@ -142,11 +142,13 @@ def initialize(controller, resources, options={})
# Initializes a new responder an invoke the proper format. If the format is
# not defined, call to_format.
+ #
def self.call(*args)
new(*args).respond
end
# Main entry point for responder responsible to dispatch to the proper format.
+ #
def respond
method = "to_#{format}"
respond_to?(method) ? send(method) : to_format
@@ -154,6 +156,7 @@ def respond
# HTML format does not render the resource, it always attempt to render a
# template.
+ #
def to_html
default_render
rescue ActionView::MissingTemplate => e
@@ -168,6 +171,7 @@ def to_js
# All other formats follow the procedure below. First we try to render a
# template, if the template is not available, we verify if the resource
# responds to :to_format and display it.
+ #
def to_format
if get? || !has_errors? || response_overridden?
default_render
@@ -205,12 +209,14 @@ def api_behavior(error)
end
# Checks whether the resource responds to the current format or not.
+ #
def resourceful?
resource.respond_to?("to_#{format}")
end
# Returns the resource location by retrieving it from the options or
# returning the resources array.
+ #
def resource_location
options[:location] || resources
end
@@ -219,6 +225,7 @@ def resource_location
# If a response block was given, use it, otherwise call render on
# controller.
+ #
def default_render
if @default_response
@default_response.call(options)
@@ -243,6 +250,7 @@ def default_render
# Results in:
#
# render :xml => @user, :status => :created
+ #
def display(resource, given_options={})
controller.render given_options.merge!(options).merge!(format => resource)
end
@@ -252,12 +260,14 @@ def display_errors
end
# Check whether the resource has errors.
+ #
def has_errors?
resource.respond_to?(:errors) && !resource.errors.empty?
end
# By default, render the <code>:edit</code> action for HTML requests with errors, unless
# the verb was POST.
+ #
def default_action
@action ||= DEFAULT_ACTIONS_FOR_VERBS[request.request_method_symbol]
end
View
1  actionpack/lib/action_controller/metal/streaming.rb
@@ -194,6 +194,7 @@ module ActionController #:nodoc:
# ==== Passenger
#
# To be described.
+ #
module Streaming
extend ActiveSupport::Concern
View
2  actionpack/lib/action_dispatch/http/mime_negotiation.rb
@@ -46,6 +46,7 @@ def accepts
# GET /posts/5.xml | request.format => Mime::XML
# GET /posts/5.xhtml | request.format => Mime::HTML
# GET /posts/5 | request.format => Mime::HTML or MIME::JS, or request.accepts.first
+ #
def format(view_path = [])
formats.first
end
@@ -81,6 +82,7 @@ def format=(extension)
# Receives an array of mimes and return the first user sent mime that
# matches the order array.
+ #
def negotiate_mime(order)
formats.each do |priority|
if priority == Mime::ALL
View
1  actionpack/lib/action_dispatch/middleware/reloader.rb
@@ -22,6 +22,7 @@ module ActionDispatch
# is false. Callbacks may be registered even when it is not included in the
# middleware stack, but are executed only when <tt>ActionDispatch::Reloader.prepare!</tt>
# or <tt>ActionDispatch::Reloader.cleanup!</tt> are called manually.
+ #
class Reloader
include ActiveSupport::Callbacks
View
1  actionpack/lib/action_dispatch/routing.rb
@@ -277,6 +277,7 @@ module ActionDispatch
# rake routes
#
# Target specific controllers by prefixing the command with <tt>CONTROLLER=x</tt>.
+ #
module Routing
autoload :Mapper, 'action_dispatch/routing/mapper'
autoload :RouteSet, 'action_dispatch/routing/route_set'
View
1  actionpack/lib/action_dispatch/routing/mapper.rb
@@ -897,6 +897,7 @@ def defaults_from_constraints(constraints)
# resources :articles, :id => /[^\/]+/
#
# This allows any character other than a slash as part of your +:id+.
+ #
module Resources
# CANONICAL_ACTIONS holds all actions that does not need a prefix or
# a path appended since they fit properly in their scope level.
View
2  actionpack/lib/action_dispatch/routing/polymorphic_routes.rb
@@ -51,6 +51,7 @@ module Routing
#
# polymorphic_url([blog, @post]) # calls blog.post_path(@post)
# form_for([blog, @post]) # => "/blog/posts/1"
+ #
module PolymorphicRoutes
# Constructs a call to a named RESTful route for the given record and returns the
# resulting URL string. For example:
@@ -83,6 +84,7 @@ module PolymorphicRoutes
#
# # the class of a record will also map to the collection
# polymorphic_url(Comment) # same as comments_url()
+ #
def polymorphic_url(record_or_hash_or_array, options = {})
if record_or_hash_or_array.kind_of?(Array)
record_or_hash_or_array = record_or_hash_or_array.compact
View
1  actionpack/lib/action_dispatch/routing/redirection.rb
@@ -121,6 +121,7 @@ module Redirection
# a string.
#
# match 'accounts/:name' => redirect(SubdomainRedirector.new('api'))
+ #
def redirect(*args, &block)
options = args.extract_options!
status = options.delete(:status) || 301
View
1  actionpack/lib/action_dispatch/routing/route_set.rb
@@ -180,6 +180,7 @@ def define_named_route_methods(name, route)
# Also allow options hash, so you can do:
#
# foo_url(bar, baz, bang, :sort_by => 'baz')
+ #
def define_url_helper(route, name, options)
selector = url_helper_name(name, options[:only_path])
View
1  actionpack/lib/action_dispatch/routing/url_for.rb
@@ -79,6 +79,7 @@ module Routing
# end
#
# User.find(1).base_uri # => "/users/1"
+ #
module UrlFor
extend ActiveSupport::Concern
include PolymorphicRoutes
View
1  actionpack/lib/action_dispatch/testing/assertions/routing.rb
@@ -140,6 +140,7 @@ def assert_routing(path, options, defaults={}, extras={}, message=nil)
# end
# end
# end
+ #
def with_routing
old_routes, @routes = @routes, ActionDispatch::Routing::RouteSet.new
if defined?(@controller) && @controller
View
1  actionpack/lib/action_view/helpers/asset_tag_helpers/stylesheet_tag_helpers.rb
@@ -139,6 +139,7 @@ def stylesheet_url(source)
# you have too many stylesheets for IE to load.
#
# stylesheet_link_tag :all, :concat => true
+ #
def stylesheet_link_tag(*sources)
@stylesheet_include ||= StylesheetIncludeTag.new(config, asset_paths)
@stylesheet_include.include_tag(*sources)
View
1  actionpack/lib/action_view/helpers/capture_helper.rb
@@ -33,6 +33,7 @@ module CaptureHelper
# <body>
# <b><%= @greeting %></b>
# </body></html>
+ #
def capture(*args)
value = nil
buffer = with_output_buffer { value = yield(*args) }
View
11 actionpack/lib/action_view/helpers/form_helper.rb
@@ -763,6 +763,7 @@ def label(object_name, method, content_or_options = nil, options = nil, &block)
#
# text_field(:snippet, :code, :size => 20, :class => 'code_input')
# # => <input type="text" id="snippet_code" name="snippet[code]" size="20" value="#{@snippet.code}" class="code_input" />
+ #
def text_field(object_name, method, options = {})
Tags::TextField.new(object_name, method, self, options).render
end
@@ -784,6 +785,7 @@ def text_field(object_name, method, options = {})
#
# password_field(:account, :pin, :size => 20, :class => 'form_input')
# # => <input type="password" id="account_pin" name="account[pin]" size="20" class="form_input" />
+ #
def password_field(object_name, method, options = {})
Tags::PasswordField.new(object_name, method, self, options).render
end
@@ -822,6 +824,7 @@ def hidden_field(object_name, method, options = {})
#
# file_field(:attachment, :file, :class => 'file_input')
# # => <input type="file" id="attachment_file" name="attachment[file]" class="file_input" />
+ #
def file_field(object_name, method, options = {})
Tags::FileField.new(object_name, method, self, options).render
end
@@ -910,6 +913,7 @@ def text_area(object_name, method, options = {})
# check_box("eula", "accepted", { :class => 'eula_check' }, "yes", "no")
# # => <input name="eula[accepted]" type="hidden" value="no" />
# # <input type="checkbox" class="eula_check" id="eula_accepted" name="eula[accepted]" value="yes" />
+ #
def check_box(object_name, method, options = {}, checked_value = "1", unchecked_value = "0")
Tags::CheckBox.new(object_name, method, self, checked_value, unchecked_value, options).render
end
@@ -962,6 +966,7 @@ def search_field(object_name, method, options = {})
#
# telephone_field("user", "phone")
# # => <input id="user_phone" name="user[phone]" type="tel" />
+ #
def telephone_field(object_name, method, options = {})
Tags::TelField.new(object_name, method, self, options).render
end
@@ -980,6 +985,7 @@ def telephone_field(object_name, method, options = {})
# @user.born_on = Date.new(1984, 1, 27)
# date_field("user", "born_on", value: "1984-05-12")
# # => <input id="user_born_on" name="user[born_on]" type="date" value="1984-05-12" />
+ #
def date_field(object_name, method, options = {})
Tags::DateField.new(object_name, method, self, options).render
end
@@ -996,6 +1002,7 @@ def date_field(object_name, method, options = {})
# === Example
# time_field("task", "started_at")
# # => <input id="task_started_at" name="task[started_at]" type="time" />
+ #
def time_field(object_name, method, options = {})
Tags::TimeField.new(object_name, method, self, options).render
end
@@ -1004,6 +1011,7 @@ def time_field(object_name, method, options = {})
#
# url_field("user", "homepage")
# # => <input id="user_homepage" name="user[homepage]" type="url" />
+ #
def url_field(object_name, method, options = {})
Tags::UrlField.new(object_name, method, self, options).render
end
@@ -1012,6 +1020,7 @@ def url_field(object_name, method, options = {})
#
# email_field("user", "address")
# # => <input id="user_address" name="user[address]" type="email" />
+ #
def email_field(object_name, method, options = {})
Tags::EmailField.new(object_name, method, self, options).render
end
@@ -1191,6 +1200,7 @@ def file_field(method, options = {})
# submit:
# post:
# create: "Add %{model}"
+ #
def submit(value=nil, options={})
value, options = nil, value if value.is_a?(Hash)
value ||= submit_default_value
@@ -1223,6 +1233,7 @@ def submit(value=nil, options={})
# submit:
# post:
# create: "Add %{model}"
+ #
def button(value=nil, options={})
value, options = nil, value if value.is_a?(Hash)
value ||= submit_default_value
View
3  actionpack/lib/action_view/helpers/form_options_helper.rb
@@ -98,6 +98,7 @@ module Helpers
# <option value="3">Jokes</option>
# <option value="4">Poems</option>
# </select>
+ #
module FormOptionsHelper
# ERB::Util can mask some helpers like textilize. Make sure to include them.
include TextHelper
@@ -153,6 +154,7 @@ module FormOptionsHelper
# key in the query string, that works for ordinary forms.
#
# In case if you don't want the helper to generate this hidden field you can specify <tt>:include_blank => false</tt> option.
+ #
def select(object, method, choices, options = {}, html_options = {})
Tags::Select.new(object, method, self, choices, options, html_options).render
end
@@ -239,6 +241,7 @@ def collection_select(object, method, collection, value_method, text_method, opt
# <option value="2">Ireland</option>
# </optgroup>
# </select>
+ #
def grouped_collection_select(object, method, collection, group_method, group_label_method, option_key_method, option_value_method, options = {}, html_options = {})
Tags::GroupedCollectionSelect.new(object, method, self, collection, group_method, group_label_method, option_key_method, option_value_method, options, html_options).render
end
View
3  actionpack/lib/action_view/helpers/form_tag_helper.rb
@@ -63,6 +63,7 @@ module FormTagHelper
#
# form_tag('http://far.away.com/form', :authenticity_token => "cf50faa3fe97702ca1ae")
# # form with custom authenticity token
+ #
def form_tag(url_for_options = {}, options = {}, &block)
html_options = html_options_for_form(url_for_options, options)
if block_given?
@@ -408,6 +409,7 @@ def radio_button_tag(name, value, checked = false, options = {})
#
# submit_tag "Save", :confirm => "Are you sure?"
# # => <input name='commit' type='submit' value='Save' data-confirm="Are you sure?" />
+ #
def submit_tag(value = "Save changes", options = {})
options = options.stringify_keys
@@ -444,6 +446,7 @@ def submit_tag(value = "Save changes", options = {})
# # => <button name="button" type="button">
# # <strong>Ask me!</strong>
# # </button>
+ #
def button_tag(content_or_options = nil, options = nil, &block)
options = content_or_options if block_given? && content_or_options.is_a?(Hash)
options ||= {}
View
1  actionpack/lib/action_view/helpers/number_helper.rb
@@ -514,6 +514,7 @@ def number_to_human_size(number, options = {})
# number_to_human(343, :units => :distance, :precision => 1) # => "300 meters"
# number_to_human(1, :units => :distance) # => "1 meter"
# number_to_human(0.34, :units => :distance) # => "34 centimeters"
+ #
def number_to_human(number, options = {})
options = options.symbolize_keys
View
1  actionpack/lib/action_view/helpers/output_safety_helper.rb
@@ -26,6 +26,7 @@ def raw(stringish)
#
# safe_join(["<p>foo</p>".html_safe, "<p>bar</p>".html_safe], "<br />".html_safe)
# # => "<p>foo</p><br /><p>bar</p>"
+ #
def safe_join(array, sep=$,)
sep = ERB::Util.html_escape(sep)
View
2  actionpack/lib/action_view/helpers/record_tag_helper.rb
@@ -29,6 +29,7 @@ module RecordTagHelper
#
# <div id="person_123" class="person foo"> Joe Bloggs </div>
# <div id="person_124" class="person foo"> Jane Bloggs </div>
+ #
def div_for(record, *args, &block)
content_tag_for(:div, record, *args, &block)
end
@@ -78,6 +79,7 @@ def div_for(record, *args, &block)
# produces:
#
# <li id="person_123" class="person bar">...
+ #
def content_tag_for(tag_name, single_or_multiple_records, prefix = nil, options = nil, &block)
options, prefix = prefix, nil if prefix.is_a?(Hash)
View
1  actionpack/lib/action_view/helpers/rendering_helper.rb
@@ -75,6 +75,7 @@ def render(options = {}, locals = {}, &block)
# <html>
# Hello David
# </html>
+ #
def _layout_for(*args, &block)
name = args.first
View
12 actionpack/lib/action_view/helpers/sanitize_helper.rb
@@ -55,6 +55,7 @@ module SanitizeHelper
# resulting markup is valid (conforming to a document type) or even well-formed.
# The output may still contain e.g. unescaped '<', '>', '&' characters and
# confuse browsers.
+ #
def sanitize(html, options = {})
self.class.white_list_sanitizer.sanitize(html, options).try(:html_safe)
end
@@ -143,6 +144,7 @@ def sanitized_protocol_separator=(value)
# class Application < Rails::Application
# config.action_view.full_sanitizer = MySpecialSanitizer.new
# end
+ #
def full_sanitizer
@full_sanitizer ||= HTML::FullSanitizer.new
end
@@ -153,6 +155,7 @@ def full_sanitizer
# class Application < Rails::Application
# config.action_view.link_sanitizer = MySpecialSanitizer.new
# end
+ #
def link_sanitizer
@link_sanitizer ||= HTML::LinkSanitizer.new
end
@@ -163,6 +166,7 @@ def link_sanitizer
# class Application < Rails::Application
# config.action_view.white_list_sanitizer = MySpecialSanitizer.new
# end
+ #
def white_list_sanitizer
@white_list_sanitizer ||= HTML::WhiteListSanitizer.new
end
@@ -172,6 +176,7 @@ def white_list_sanitizer
# class Application < Rails::Application
# config.action_view.sanitized_uri_attributes = 'lowsrc', 'target'
# end
+ #
def sanitized_uri_attributes=(attributes)
HTML::WhiteListSanitizer.uri_attributes.merge(attributes)
end
@@ -181,6 +186,7 @@ def sanitized_uri_attributes=(attributes)
# class Application < Rails::Application
# config.action_view.sanitized_bad_tags = 'embed', 'object'
# end
+ #
def sanitized_bad_tags=(attributes)
HTML::WhiteListSanitizer.bad_tags.merge(attributes)
end
@@ -190,6 +196,7 @@ def sanitized_bad_tags=(attributes)
# class Application < Rails::Application
# config.action_view.sanitized_allowed_tags = 'table', 'tr', 'td'
# end
+ #
def sanitized_allowed_tags=(attributes)
HTML::WhiteListSanitizer.allowed_tags.merge(attributes)
end
@@ -199,6 +206,7 @@ def sanitized_allowed_tags=(attributes)
# class Application < Rails::Application
# config.action_view.sanitized_allowed_attributes = 'onclick', 'longdesc'
# end
+ #
def sanitized_allowed_attributes=(attributes)
HTML::WhiteListSanitizer.allowed_attributes.merge(attributes)
end
@@ -208,6 +216,7 @@ def sanitized_allowed_attributes=(attributes)
# class Application < Rails::Application
# config.action_view.sanitized_allowed_css_properties = 'expression'
# end
+ #
def sanitized_allowed_css_properties=(attributes)
HTML::WhiteListSanitizer.allowed_css_properties.merge(attributes)
end
@@ -217,6 +226,7 @@ def sanitized_allowed_css_properties=(attributes)
# class Application < Rails::Application
# config.action_view.sanitized_allowed_css_keywords = 'expression'
# end
+ #
def sanitized_allowed_css_keywords=(attributes)
HTML::WhiteListSanitizer.allowed_css_keywords.merge(attributes)
end
@@ -226,6 +236,7 @@ def sanitized_allowed_css_keywords=(attributes)
# class Application < Rails::Application
# config.action_view.sanitized_shorthand_css_properties = 'expression'
# end
+ #
def sanitized_shorthand_css_properties=(attributes)
HTML::WhiteListSanitizer.shorthand_css_properties.merge(attributes)
end
@@ -235,6 +246,7 @@ def sanitized_shorthand_css_properties=(attributes)
# class Application < Rails::Application
# config.action_view.sanitized_allowed_protocols = 'ssh', 'feed'
# end
+ #
def sanitized_allowed_protocols=(attributes)
HTML::WhiteListSanitizer.allowed_protocols.merge(attributes)
end
View
1  actionpack/lib/action_view/helpers/tags/select.rb
@@ -31,6 +31,7 @@ def render
#
# [nil, []]
# { nil => [] }
+ #
def grouped_choices?
!@choices.empty? && @choices.first.respond_to?(:last) && Array === @choices.first.last
end
View
1  actionpack/lib/action_view/helpers/url_helper.rb
@@ -586,6 +586,7 @@ def mail_to(email_address, name = nil, html_options = {})
#
# current_page?(:controller => 'product', :action => 'index')
# # => false
+ #
def current_page?(options)
unless request
raise "You cannot use helpers that need to determine the current " \
View
1  actionpack/lib/action_view/template/resolver.rb
@@ -215,6 +215,7 @@ def extract_handler_and_format(path, default_formats)
# * <tt>:locale</tt> - possible locale versions
# * <tt>:formats</tt> - possible request formats (for example html, json, xml...)
# * <tt>:handlers</tt> - possible handlers (for example erb, haml, builder...)
+ #
class FileSystemResolver < PathResolver
def initialize(path, pattern=nil)
raise ArgumentError, "path already is a Resolver class" if path.is_a?(Resolver)
View
1  activemodel/lib/active_model/attribute_methods.rb
@@ -53,6 +53,7 @@ class MissingAttributeError < NoMethodError
# hash value.
#
# Hash keys must be strings.
+ #
module AttributeMethods
extend ActiveSupport::Concern
View
1  activemodel/lib/active_model/callbacks.rb
@@ -83,6 +83,7 @@ def self.extended(base)
# # obj is the MyModel instance that the callback is being called on
# end
# end
+ #
def define_model_callbacks(*callbacks)
options = callbacks.extract_options!
options = {
View
1  activemodel/lib/active_model/conversion.rb
@@ -22,6 +22,7 @@ module ActiveModel
# cm.to_key # => nil
# cm.to_param # => nil
# cm.to_partial_path # => "contact_messages/contact_message"
+ #
module Conversion
extend ActiveSupport::Concern
View
1  activemodel/lib/active_model/errors.rb
@@ -317,6 +317,7 @@ def full_message(attribute, message)
# * <tt>activemodel.errors.messages.blank</tt>
# * <tt>errors.attributes.title.blank</tt>
# * <tt>errors.messages.blank</tt>
+ #
def generate_message(attribute, type = :invalid, options = {})
type = options.delete(:message) if options[:message].is_a?(Symbol)
View
2  activemodel/lib/active_model/lint.rb
@@ -52,6 +52,7 @@ def model.persisted?() false end
#
# Returns a string giving a relative path. This is used for looking up
# partials. For example, a BlogPost model might return "blog_posts/blog_post"
+ #
def test_to_partial_path
assert model.respond_to?(:to_partial_path), "The model should respond to to_partial_path"
assert_kind_of String, model.to_partial_path
@@ -73,6 +74,7 @@ def test_persisted?
#
# Model.model_name must return a string with some convenience methods:
# :human, :singular, and :plural. Check ActiveModel::Naming for more information.
+ #
def test_model_naming
assert model.class.respond_to?(:model_name), "The model should respond to model_name"
model_name = model.class.model_name
View
2  activemodel/lib/active_model/mass_assignment_security.rb
@@ -56,6 +56,8 @@ module MassAssignmentSecurity
#
# You can specify your own sanitizer object eg. MySanitizer.new.
# See <tt>ActiveModel::MassAssignmentSecurity::LoggerSanitizer</tt> for example implementation.
+ #
+ #
module ClassMethods
# Attributes named in this macro are protected from mass-assignment
# whenever attributes are sanitized before assignment. A role for the
View
2  activemodel/lib/active_model/observing.rb
@@ -124,6 +124,7 @@ def inherited(subclass)
#
# This will call +custom_notification+, passing as arguments
# the current object and :foo.
+ #
def notify_observers(method, *extra_args)
self.class.notify_observers(method, self, *extra_args)
end
@@ -191,6 +192,7 @@ def notify_observers(method, *extra_args)
# If you're using an Observer in a Rails application with Active Record, be sure to
# read about the necessary configuration in the documentation for
# ActiveRecord::Observer.
+ #
class Observer
include Singleton
extend ActiveSupport::DescendantsTracker
View
1  activemodel/lib/active_model/serialization.rb
@@ -115,6 +115,7 @@ def serializable_hash(options = nil)
# @data[key]
# end
# end
+ #
alias :read_attribute_for_serialization :send
# Add associations specified via the <tt>:include</tt> option.
View
2  activemodel/lib/active_model/validations.rb
@@ -38,6 +38,7 @@ module ActiveModel
# Note that <tt>ActiveModel::Validations</tt> automatically adds an +errors+ method
# to your instances initialized with a new <tt>ActiveModel::Errors</tt> object, so
# there is no need for you to do this manually.
+ #
module Validations
extend ActiveSupport::Concern
@@ -221,6 +222,7 @@ def invalid?(context = nil)
# @data[key]
# end
# end
+ #
alias :read_attribute_for_validation :send
protected
View
1  activemodel/lib/active_model/validations/validates.rb
@@ -77,6 +77,7 @@ module ClassMethods
# Or to all at the same time:
#
# validates :password, :presence => true, :confirmation => true, :if => :password_required?
+ #
def validates(*attributes)
defaults = attributes.extract_options!.dup
validations = defaults.slice!(*_validates_default_keys)
View
2  activemodel/lib/active_model/validator.rb
@@ -94,6 +94,7 @@ module ActiveModel #:nodoc:
#
# This setup method is only called when used with validation macros or the
# class level <tt>validates_with</tt> method.
+ #
class Validator
attr_reader :options
@@ -101,6 +102,7 @@ class Validator
#
# PresenceValidator.kind # => :presence
# UniquenessValidator.kind # => :uniqueness
+ #
def self.kind
@kind ||= name.split('::').last.underscore.sub(/_validator$/, '').to_sym unless anonymous?
end
View
1  activemodel/test/cases/validations/i18n_validation_test.rb
@@ -65,6 +65,7 @@ def test_errors_full_messages_uses_format
# A set of common cases for ActiveModel::Validations message generation that
# are used to generate tests to keep things DRY
+ #
COMMON_CASES = [
# [ case, validation_options, generate_message_options]
[ "given no options", {}, {}],
View
2  activerecord/lib/active_record/aggregations.rb
@@ -166,6 +166,7 @@ def clear_aggregation_cache #:nodoc:
# finds all customers with +balance_amount+ equal to 20 and +balance_currency+ equal to "USD":
#
# Customer.where(:balance => Money.new(20, "USD")).all
+ #
module ClassMethods
# Adds reader and writer methods for manipulating a value object:
# <tt>composed_of :address</tt> adds <tt>address</tt> and <tt>address=(new_address)</tt> methods.
@@ -206,6 +207,7 @@ module ClassMethods
# :mapping => %w(ip to_i),
# :constructor => Proc.new { |ip| IPAddr.new(ip, Socket::AF_INET) },
# :converter => Proc.new { |ip| ip.is_a?(Integer) ? IPAddr.new(ip, Socket::AF_INET) : IPAddr.new(ip.to_s) }
+ #
def composed_of(part_id, options = {})
options.assert_valid_keys(:class_name, :mapping, :allow_nil, :constructor, :converter)
View
1  activerecord/lib/active_record/associations/association.rb
@@ -34,6 +34,7 @@ def initialize(owner, reflection)
# Returns the name of the table of the related class:
#
# post.comments.aliased_table_name # => "comments"
+ #
def aliased_table_name
klass.table_name
end
View
1  activerecord/lib/active_record/callbacks.rb
@@ -229,6 +229,7 @@ module ActiveRecord
# Topic._save_callbacks.select { |cb| cb.kind.eql?(:before) }.collect(&:filter).include?(:rest_when_dead)
#
# Returns true or false depending on whether the proc is contained in the before_save callback chain on a Topic model.
+ #
module Callbacks
# We can't define callbacks directly on ActiveRecord::Model because
# it is a module. So we queue up the definitions and execute them
View
1  activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb
@@ -339,6 +339,7 @@ def native
# t.remove_index
# t.remove_timestamps
# end
+ #
class Table
def initialize(table_name, base)
@table_name = table_name
View
1  activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb
@@ -380,6 +380,7 @@ def rename_column(table_name, column_name, new_column_name)
# CREATE UNIQUE INDEX index_accounts_on_branch_id_and_party_id ON accounts(branch_id, party_id) WHERE active
#
# Note: only supported by PostgreSQL
+ #
def add_index(table_name, column_name, options = {})
index_name, index_type, index_columns, index_options = add_index_options(table_name, column_name, options)
execute "CREATE #{index_type} INDEX #{quote_column_name(index_name)} ON #{quote_table_name(table_name)} (#{index_columns})#{index_options}"
View
1  activerecord/lib/active_record/connection_adapters/mysql_adapter.rb
@@ -59,6 +59,7 @@ module ConnectionAdapters
# * <tt>:sslcert</tt> - Necessary to use MySQL with an SSL connection.
# * <tt>:sslcapath</tt> - Necessary to use MySQL with an SSL connection.
# * <tt>:sslcipher</tt> - Necessary to use MySQL with an SSL connection.
+ #
class MysqlAdapter < AbstractMysqlAdapter
class Column < AbstractMysqlAdapter::Column #:nodoc:
View
1  activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb
@@ -684,6 +684,7 @@ class ExplainPrettyPrinter # :nodoc:
# -> Seq Scan on posts (cost=0.00..28.88 rows=8 width=4)
# Filter: (posts.user_id = 1)
# (6 rows)
+ #
def pp(result)
header = result.columns.first
lines = result.rows.map(&:first)
View
1  activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb
@@ -265,6 +265,7 @@ class ExplainPrettyPrinter
#
# 0|0|0|SEARCH TABLE users USING INTEGER PRIMARY KEY (rowid=?) (~1 rows)
# 0|1|1|SCAN TABLE posts (~100000 rows)
+ #
def pp(result) # :nodoc:
result.rows.map do |row|
row.join('|')
View
1  activerecord/lib/active_record/locking/optimistic.rb
@@ -46,6 +46,7 @@ module Locking
# class Person < ActiveRecord::Base
# self.locking_column = :lock_person
# end
+ #
module Optimistic
extend ActiveSupport::Concern
View
1  activerecord/lib/active_record/model.rb
@@ -7,6 +7,7 @@ module ActiveRecord
# class Post
# include ActiveRecord::Model
# end
+ #
module Model
module ClassMethods #:nodoc:
include ActiveSupport::Callbacks::ClassMethods
View
1  activerecord/lib/active_record/observer.rb
@@ -87,6 +87,7 @@ module ActiveRecord
# If by any chance you are using observed models in the initialization you can still
# load their observers by calling <tt>ModelObserver.instance</tt> before. Observers are
# singletons and that call instantiates and registers them.
+ #
class Observer < ActiveModel::Observer
protected
View
1  activerecord/lib/active_record/persistence.rb
@@ -158,6 +158,7 @@ def becomes(klass)
# * Callbacks are invoked.
# * updated_at/updated_on column is updated if that column is available.
# * Updates all the attributes that are dirty in this object.
+ #
def update_attribute(name, value)
name = name.to_s
verify_readonly_attribute(name)
View
6 activerecord/lib/active_record/reflection.rb
@@ -42,6 +42,7 @@ def reflect_on_all_aggregations
# Returns the AggregateReflection object for the named +aggregation+ (use the symbol).
#
# Account.reflect_on_aggregation(:balance) # => the balance AggregateReflection
+ #
def reflect_on_aggregation(aggregation)
reflection = reflections[aggregation]
reflection if reflection.is_a?(AggregateReflection)
@@ -56,6 +57,7 @@ def reflect_on_aggregation(aggregation)
#
# Account.reflect_on_all_associations # returns an array of all associations
# Account.reflect_on_all_associations(:has_many) # returns an array of all has_many associations
+ #
def reflect_on_all_associations(macro = nil)
association_reflections = reflections.values.grep(AssociationReflection)
macro ? association_reflections.select { |reflection| reflection.macro == macro } : association_reflections
@@ -65,6 +67,7 @@ def reflect_on_all_associations(macro = nil)
#
# Account.reflect_on_association(:owner) # returns the owner AssociationReflection
# Invoice.reflect_on_association(:line_items).macro # returns :has_many
+ #
def reflect_on_association(association)
reflection = reflections[association]
reflection if reflection.is_a?(AssociationReflection)
@@ -383,6 +386,7 @@ class ThroughReflection < AssociationReflection #:nodoc:
# has_many :taggings
# has_many :tags, :through => :taggings
# end
+ #
def source_reflection
@source_reflection ||= source_reflection_names.collect { |name| through_reflection.klass.reflect_on_association(name) }.compact.first
end
@@ -397,6 +401,7 @@ def source_reflection
#
# tags_reflection = Post.reflect_on_association(:tags)
# taggings_reflection = tags_reflection.through_reflection
+ #
def through_reflection
@through_reflection ||= active_record.reflect_on_association(options[:through])
end
@@ -483,6 +488,7 @@ def association_primary_key(klass = nil)
# Gets an array of possible <tt>:through</tt> source reflection names:
#
# [:singularized, :pluralized]
+ #
def source_reflection_names
@source_reflection_names ||= (options[:source] ? [options[:source]] : [name.to_s.singularize, name]).collect { |n| n.to_sym }
end
View
1  activerecord/lib/active_record/relation/calculations.rb
@@ -138,6 +138,7 @@ def calculate(operation, column_name, options = {})
# Person.pluck('DATEDIFF(updated_at, created_at)')
# # SELECT DATEDIFF(updated_at, created_at) FROM people
# # => ['0', '27761', '173']
+ #
def pluck(column_name)
if column_name.is_a?(Symbol) && column_names.include?(column_name.to_s)
column_name = "#{table_name}.#{column_name}"
View
1  activerecord/lib/active_record/relation/finder_methods.rb
@@ -49,6 +49,7 @@ def find(*args)
#
# Post.find_by name: 'Spartacus', rating: 4
# Post.find_by "published_at < ?", 2.weeks.ago
+ #
def find_by(*args)
where(*args).take
end
View
3  activerecord/lib/active_record/relation/query_methods.rb
@@ -163,6 +163,7 @@ def order!(*args)
# User.order('email DESC').reorder('id ASC').order('name ASC')
#
# generates a query with 'ORDER BY id ASC, name ASC'.
+ #
def reorder(*args)
args.blank? ? self : spawn.reorder!(*args)
end
@@ -276,6 +277,7 @@ def lock!(locks = true)
# Post.none # => returning [] instead breaks the previous code
# end
# end
+ #
def none
NullRelation.new(@klass, @table)
end
@@ -310,6 +312,7 @@ def create_with!(value)
#
# Topics.select('a.title').from(Topics.approved, :a)
# # => SELECT a.title FROM (SELECT * FROM topics WHERE approved = 't') a
+ #
def from(value, subquery_name = nil)
spawn.from!(value, subquery_name)
end
View
3  activerecord/lib/active_record/relation/spawn_methods.rb
@@ -23,6 +23,7 @@ def spawn #:nodoc:
# Post.where(:published => true).merge(recent_posts)
# # Returns the intersection of all published posts with the 5 most recently created posts.
# # (This is just an example. You'd probably want to do this with a single query!)
+ #
def merge(other)
if other.is_a?(Array)
to_a & other
@@ -44,6 +45,7 @@ def merge!(other)
#
# Post.order('id asc').except(:order) # discards the order condition
# Post.where('id > 10').order('id asc').except(:where) # discards the where condition but keeps the order
+ #
def except(*skips)
result = Relation.new(klass, table, values.except(*skips))
result.default_scoped = default_scoped
@@ -57,6 +59,7 @@ def except(*skips)
#
# Post.order('id asc').only(:where) # discards the order condition
# Post.order('id asc').only(:where, :order) # uses the specified order
+ #
def only(*onlies)
result = Relation.new(klass, table, values.slice(*onlies))
result.default_scoped = default_scoped
View
1  activerecord/lib/active_record/validations/uniqueness.rb
@@ -198,6 +198,7 @@ module ClassMethods
# * ActiveRecord::ConnectionAdapters::Mysql2Adapter
# * ActiveRecord::ConnectionAdapters::SQLite3Adapter
# * ActiveRecord::ConnectionAdapters::PostgreSQLAdapter
+ #
def validates_uniqueness_of(*attr_names)
validates_with UniquenessValidator, _merge_attributes(attr_names)
end
View
1  activerecord/test/cases/attribute_methods_test.rb
@@ -719,6 +719,7 @@ def test_bulk_update_respects_access_control
def test_read_attribute_overwrites_private_method_not_considered_implemented
# simulate a model with a db column that shares its name an inherited
# private method (e.g. Object#system)
+ #
Object.class_eval do
private
def title; "private!"; end
View
1  activerecord/test/cases/validations/i18n_validation_test.rb
@@ -33,6 +33,7 @@ def replied_topic
# A set of common cases for ActiveModel::Validations message generation that
# are used to generate tests to keep things DRY
+ #
COMMON_CASES = [
# [ case, validation_options, generate_message_options]
[ "given no options", {}, {}],
View
1  activerecord/test/models/subject.rb
@@ -1,4 +1,5 @@
# used for OracleSynonymTest, see test/synonym_test_oracle.rb
+#
class Subject < ActiveRecord::Base
# added initialization of author_email_address in the same way as in Topic class
View
1  activesupport/lib/active_support/benchmarkable.rb
@@ -44,6 +44,7 @@ def benchmark(message = "Benchmarking", options = {})
end
# Silence the logger during the execution of the block.
+ #
def silence
old_logger_level, logger.level = logger.level, ::Logger::ERROR if logger
yield
View
1  activesupport/lib/active_support/callbacks.rb
@@ -341,6 +341,7 @@ def #{name}() #{chain.compile} end
# This is used internally to append, prepend and skip callbacks to the
# CallbackChain.
+ #
def __update_callbacks(name, filters = [], block = nil) #:nodoc:
type = filters.first.in?([:before, :after, :around]) ? filters.shift : :before
options = filters.last.is_a?(Hash) ? filters.pop : {}
View
1  activesupport/lib/active_support/concern.rb
@@ -94,6 +94,7 @@ module ActiveSupport
# class Host
# include Bar # works, Bar takes care now of its dependencies
# end
+ #
module Concern
def self.extended(base)
base.instance_variable_set("@_dependencies", [])
View
2  activesupport/lib/active_support/configurable.rb
@@ -48,6 +48,7 @@ def configure
# user = User.new
# user.allowed_access = true
# user.allowed_access # => true
+ #
def config_accessor(*names)
options = names.extract_options!
@@ -78,6 +79,7 @@ def config_accessor(*names)
#
# user.config.allowed_access # => true
# user.config.level # => 1
+ #
def config
@_config ||= self.class.config.inheritable_copy
end
View
1  activesupport/lib/active_support/core_ext/array/conversions.rb
@@ -136,6 +136,7 @@ def to_formatted_s(format = :default)
# <user-id>1</user-id>
# </message>
# </messages>
+ #
def to_xml(options = {})
require 'active_support/builder' unless defined?(Builder)
View
1  activesupport/lib/active_support/core_ext/array/uniq_by.rb
@@ -4,6 +4,7 @@ class Array
# Returns a unique array based on the criteria in the block.
#
# [1, 2, 3, 4].uniq_by { |i| i.odd? } # => [1, 2]
+ #
def uniq_by(&block)
ActiveSupport::Deprecation.warn 'uniq_by is deprecated. Use Array#uniq instead', caller
uniq(&block)
View
2  activesupport/lib/active_support/core_ext/enumerable.rb
@@ -17,6 +17,7 @@ module Enumerable
# The default sum of an empty list is zero. You can override this default:
#
# [].sum(Payment.new(0)) { |i| i.amount } # => Payment.new(0)
+ #
def sum(identity = 0, &block)
if block_given?
map(&block).sum(identity)
@@ -31,6 +32,7 @@ def sum(identity = 0, &block)
# => { "nextangle" => <Person ...>, "chade-" => <Person ...>, ...}
# people.index_by { |person| "#{person.first_name} #{person.last_name}" }
# => { "Chade- Fowlersburg-e" => <Person ...>, "David Heinemeier Hansson" => <Person ...>, ...}
+ #
def index_by
if block_given?
Hash[map { |elem| [yield(elem), elem] }]
View
1  activesupport/lib/active_support/core_ext/hash/except.rb
@@ -10,6 +10,7 @@ class Hash
#
# {:a => 1}.with_indifferent_access.except(:a) # => {}
# {:a => 1}.with_indifferent_access.except('a') # => {}
+ #
def except(*keys)
dup.except!(*keys)
end
View
2  activesupport/lib/active_support/core_ext/hash/indifferent_access.rb
@@ -5,6 +5,7 @@ class Hash
# Returns an <tt>ActiveSupport::HashWithIndifferentAccess</tt> out of its receiver:
#
# {:a => 1}.with_indifferent_access["a"] # => 1
+ #
def with_indifferent_access
ActiveSupport::HashWithIndifferentAccess.new_from_hash_copying_default(self)
end
@@ -18,5 +19,6 @@ def with_indifferent_access
#
# b = {:b => 1}
# {:a => b}.with_indifferent_access["a"] # calls b.nested_under_indifferent_access
+ #
alias nested_under_indifferent_access with_indifferent_access
end
View
2  activesupport/lib/active_support/core_ext/integer/inflections.rb
@@ -10,6 +10,7 @@ class Integer
# 1003.ordinalize # => "1003rd"
# -11.ordinalize # => "-11th"
# -1001.ordinalize # => "-1001st"
+ #
def ordinalize
ActiveSupport::Inflector.ordinalize(self)
end
@@ -23,6 +24,7 @@ def ordinalize
# 1003.ordinal # => "rd"
# -11.ordinal # => "th"
# -1001.ordinal # => "st"
+ #
def ordinal
ActiveSupport::Inflector.ordinal(self)
end
View
2  activesupport/lib/active_support/core_ext/kernel/reporting.rb
@@ -65,6 +65,7 @@ def suppress(*exception_classes)
#
# stream = capture(:stdout) { puts 'Cool' }
# stream # => "Cool\n"
+ #
def capture(stream)
begin
stream = stream.to_s
@@ -82,6 +83,7 @@ def capture(stream)
# Silences both STDOUT and STDERR, even for subprocesses.
#
# quietly { system 'bundle install' }
+ #
def quietly
silence_stream(STDOUT) do
silence_stream(STDERR) do
View
1  activesupport/lib/active_support/core_ext/module/anonymous.rb
@@ -13,6 +13,7 @@ class Module
# m = Module.new # creates an anonymous module
# M = m # => m gets a name here as a side-effect
# m.name # => "M"
+ #
def anonymous?
name.nil?
end
View
1  activesupport/lib/active_support/core_ext/module/delegation.rb
@@ -100,6 +100,7 @@ class Module
# end
#
# Foo.new.zoo # returns nil
+ #
def delegate(*methods)
options = methods.pop
unless options.is_a?(Hash) && to = options[:to]
View
2  activesupport/lib/active_support/core_ext/module/introspection.rb
@@ -27,6 +27,7 @@ def parent_name
#
# M.parent # => Object
# Module.new.parent # => Object
+ #
def parent
parent_name ? ActiveSupport::Inflector.constantize(parent_name) : Object
end
@@ -43,6 +44,7 @@ def parent
# M.parents # => [Object]
# M::N.parents # => [M, Object]
# X.parents # => [M, Object]
+ #
def parents
parents = []
if parent_name
View
7 activesupport/lib/active_support/core_ext/object/blank.rb
@@ -43,6 +43,7 @@ class NilClass
# +nil+ is blank:
#
# nil.blank? # => true
+ #
def blank?
true
end
@@ -52,6 +53,7 @@ class FalseClass
# +false+ is blank:
#
# false.blank? # => true
+ #
def blank?
true
end
@@ -61,6 +63,7 @@ class TrueClass
# +true+ is not blank:
#
# true.blank? # => false
+ #
def blank?
false
end
@@ -71,6 +74,7 @@ class Array
#
# [].blank? # => true
# [1,2,3].blank? # => false
+ #
alias_method :blank?, :empty?
end
@@ -79,6 +83,7 @@ class Hash
#
# {}.blank? # => true
# {:key => 'value'}.blank? # => false
+ #
alias_method :blank?, :empty?
end
@@ -89,6 +94,7 @@ class String
# ' '.blank? # => true
# ' '.blank? # => true
# ' something here '.blank? # => false
+ #
def blank?
self !~ /[^[:space:]]/
end
@@ -99,6 +105,7 @@ class Numeric #:nodoc:
#
# 1.blank? # => false
# 0.blank? # => false
+ #
def blank?
false
end
View
5 activesupport/lib/active_support/core_ext/object/duplicable.rb
@@ -31,6 +31,7 @@ class NilClass
#
# nil.duplicable? # => false
# nil.dup # => TypeError: can't dup NilClass
+ #
def duplicable?
false
end
@@ -41,6 +42,7 @@ class FalseClass
#
# false.duplicable? # => false
# false.dup # => TypeError: can't dup FalseClass
+ #
def duplicable?
false
end
@@ -51,6 +53,7 @@ class TrueClass
#
# true.duplicable? # => false
# true.dup # => TypeError: can't dup TrueClass
+ #
def duplicable?
false
end
@@ -61,6 +64,7 @@ class Symbol
#
# :my_symbol.duplicable? # => false
# :my_symbol.dup # => TypeError: can't dup Symbol
+ #
def duplicable?
false
end
@@ -71,6 +75,7 @@ class Numeric
#
# 3.duplicable? # => false
# 3.dup # => TypeError: can't dup Fixnum
+ #
def duplicable?
false
end
View
1  activesupport/lib/active_support/core_ext/object/with_options.rb
@@ -36,6 +36,7 @@ class Object
#
# <tt>with_options</tt> can also be nested since the call is forwarded to its receiver.
# Each nesting level will merge inherited defaults in addition to their own.
+ #
def with_options(options)
yield ActiveSupport::OptionMerger.new(self, options)
end
View
1  activesupport/lib/active_support/core_ext/string/inflections.rb
@@ -5,6 +5,7 @@
# For instance, you can figure out the name of a table from the name of a class.
#
# 'ScaleScore'.tableize # => "scale_scores"
+#
class String
# Returns the plural form of the word in the string.
#
View
1  activesupport/lib/active_support/core_ext/string/output_safety.rb
@@ -64,6 +64,7 @@ def html_escape_once(s)
# in Rails templates:
#
# <%=j @person.to_json %>
+ #
def json_escape(s)
result = s.to_s.gsub(JSON_ESCAPE_REGEXP) { |special| JSON_ESCAPE[special] }
s.html_safe? ? result.html_safe : result
View
1  activesupport/lib/active_support/file_update_checker.rb
@@ -28,6 +28,7 @@ module ActiveSupport
# ActionDispatch::Reloader.to_prepare do
# i18n_reloader.execute_if_updated
# end
+ #
class FileUpdateChecker
# It accepts two parameters on initialization. The first is an array
# of files and the second is an optional hash of directories. The hash must
View
4 activesupport/lib/active_support/hash_with_indifferent_access.rb
@@ -53,6 +53,7 @@ def self.[](*args)
#
# hash = HashWithIndifferentAccess.new
# hash[:key] = "value"
+ #
def []=(key, value)
regular_writer(convert_key(key), convert_value(value))
end
@@ -68,6 +69,7 @@ def []=(key, value)
# hash_2[:key] = "New Value!"
#
# hash_1.update(hash_2) # => {"key"=>"New Value!"}
+ #
def update(other_hash)
if other_hash.is_a? HashWithIndifferentAccess
super(other_hash)
@@ -85,6 +87,7 @@ def update(other_hash)
# hash["key"] = "value"
# hash.key? :key # => true
# hash.key? "key" # => true
+ #
def key?(key)
super(convert_key(key))
end
@@ -104,6 +107,7 @@ def fetch(key, *extras)
# hash[:a] = "x"
# hash[:b] = "y"
# hash.values_at("a", "b") # => ["x", "y"]
+ #
def values_at(*indices)
indices.collect {|key| self[convert_key(key)]}
end
View
1  activesupport/lib/active_support/inflector/methods.rb
@@ -228,6 +228,7 @@ def constantize(camel_cased_word) #:nodoc:
# "blargle".safe_constantize # => nil
# "UnknownModule".safe_constantize # => nil
# "UnknownModule::Foo::Bar".safe_constantize # => nil
+ #
def safe_constantize(camel_cased_word)
begin
constantize(camel_cased_word)
View
1  activesupport/lib/active_support/lazy_load_hooks.rb
@@ -17,6 +17,7 @@ module ActiveSupport
# The very last line of +activerecord/lib/active_record/base.rb+ is:
#
# ActiveSupport.run_load_hooks(:active_record, ActiveRecord::Base)
+ #
@load_hooks = Hash.new { |h,k| h[k] = [] }
@loaded = Hash.new { |h,k| h[k] = [] }
View
1  activesupport/lib/active_support/log_subscriber.rb
@@ -111,6 +111,7 @@ def #{level}(progname = nil, &block)
# option is set to true, it also adds bold to the string. This is based
# on the Highline implementation and will automatically append CLEAR to the
# end of the returned String.
+ #
def color(text, color, bold=false)
return text unless colorize_logging
color = self.class.const_get(color.to_s.upcase) if color.is_a?(Symbol)
View
2  activesupport/lib/active_support/log_subscriber/test_helper.rb
@@ -31,6 +31,7 @@ class LogSubscriber
# powers (it actually does not send anything to your output), and you can collect them
# doing @logger.logged(level), where level is the level used in logging, like info,
# debug, warn and so on.
+ #
module TestHelper
def setup
@logger = MockLogger.new
@@ -95,6 +96,7 @@ def wait
# def logger
# ActiveRecord::Base.logger = @logger
# end
+ #
def set_logger(logger)
ActiveSupport::LogSubscriber.logger = logger
end
View
1  activesupport/lib/active_support/message_encryptor.rb
@@ -36,6 +36,7 @@ class InvalidMessage < StandardError; end
# Options:
# * <tt>:cipher</tt> - Cipher to use. Can be any cipher returned by <tt>OpenSSL::Cipher.ciphers</tt>. Default is 'aes-256-cbc'
# * <tt>:serializer</tt> - Object serializer to use. Default is +Marshal+.
+ #
def initialize(secret, options = {})
@secret = secret
@cipher = options[:cipher] || 'aes-256-cbc'
View
1  activesupport/lib/active_support/notifications.rb
@@ -133,6 +133,7 @@ module ActiveSupport
#
# Notifications ships with a queue implementation that consumes and publish events
# to log subscribers in a thread. You can use any queue implementation you want.
+ #
module Notifications
@instrumenters = Hash.new { |h,k| h[k] = notifier.listening?(k) }
View
1  activesupport/lib/active_support/ordered_options.rb
@@ -13,6 +13,7 @@
# h.girl = 'Mary'
# h.boy # => 'John'
# h.girl # => 'Mary'
+#
module ActiveSupport #:nodoc:
class OrderedOptions < Hash
alias_method :_get, :[] # preserve the original #[] method
View
1  activesupport/lib/active_support/string_inquirer.rb
@@ -8,6 +8,7 @@ module ActiveSupport
# you can call this:
#
# Rails.env.production?
+ #
class StringInquirer < String
def method_missing(method_name, *arguments)
if method_name[-1, 1] == "?"
View
2  activesupport/lib/active_support/time_with_zone.rb
@@ -31,6 +31,7 @@ module ActiveSupport
# t > Time.utc(1999) # => true
# t.is_a?(Time) # => true
# t.is_a?(ActiveSupport::TimeWithZone) # => true
+ #
class TimeWithZone
# Report class name as 'Time' to thwart type checking
@@ -126,6 +127,7 @@ def xmlschema(fraction_digits = 0)
# # With ActiveSupport::JSON::Encoding.use_standard_json_time_format = false
# Time.utc(2005,2,1,15,15,10).in_time_zone.to_json
# # => "2005/02/01 15:15:10 +0000"
+ #
def as_json(options = nil)
if ActiveSupport::JSON::Encoding.use_standard_json_time_format
xmlschema
View
1  railties/lib/rails/application.rb
@@ -48,6 +48,7 @@ module Rails
# 10) Build the middleware stack and run to_prepare callbacks
# 11) Run config.before_eager_load and eager_load if cache classes is true
# 12) Run config.after_initialize callbacks
+ #
class Application < Engine
autoload :Bootstrap, 'rails/application/bootstrap'
autoload :Configuration, 'rails/application/configuration'
View
1  railties/lib/rails/configuration.rb
@@ -32,6 +32,7 @@ module Configuration
# And finally they can also be removed from the stack completely:
#
# config.middleware.delete ActionDispatch::BestStandardsSupport
+ #
class MiddlewareStackProxy
def initialize
@operations = []
View
1  railties/lib/rails/engine/configuration.rb
@@ -28,6 +28,7 @@ def middleware
# If you want to disable color in console, do:
#
# config.generators.colorize_logging = false
+ #
def generators #:nodoc:
@generators ||= Rails::Configuration::Generators.new
yield(@generators) if block_given?
View
1  railties/lib/rails/generators/active_model.rb
@@ -22,6 +22,7 @@ module Generators
#
# The only exception in ActiveModel for ActiveRecord is the use of self.build
# instead of self.new.
+ #
class ActiveModel
attr_reader :name
View
1  railties/lib/rails/generators/base.rb
@@ -161,6 +161,7 @@ def self.hide!
# hook_for :resource_controller do |instance, controller|
# instance.invoke controller, [ instance.name.pluralize ]
# end
+ #
def self.hook_for(*names, &block)
options = names.extract_options!
in_base = options.delete(:in) || base_name
View
1  railties/lib/rails/generators/named_base.rb
@@ -168,6 +168,7 @@ def pluralize_table_names?
#
# If the generator is invoked with class name Admin, it will check for
# the presence of "AdminObserver".
+ #
def self.check_class_collision(options={})
define_method :check_class_collision do
name = if self.respond_to?(:controller_class_name) # for ScaffoldBase
View
2  railties/lib/rails/generators/resource_helpers.rb
@@ -4,6 +4,7 @@ module Rails
module Generators
# Deal with controller names on scaffold and add some helpers to deal with
# ActiveModel.
+ #
module ResourceHelpers
mattr_accessor :skip_warn
@@ -12,6 +13,7 @@ def self.included(base) #:nodoc:
end
# Set controller variables on initialization.
+ #
def initialize(*args) #:nodoc:
super
View
13 railties/lib/rails/generators/test_case.rb
@@ -26,6 +26,7 @@ module Generators
# destination File.expand_path("../tmp", File.dirname(__FILE__))
# setup :prepare_destination
# end
+ #
class TestCase < ActiveSupport::TestCase
include FileUtils