From 05fdb310b6e27a399ef3e99e32f319a1ef37bab1 Mon Sep 17 00:00:00 2001 From: Oscar Del Ben Date: Sat, 19 May 2012 10:02:16 -0700 Subject: Getting started guide has been completely rewritten and edited. --- guides/source/getting_started.textile | 2 -- 1 file changed, 2 deletions(-) diff --git a/guides/source/getting_started.textile b/guides/source/getting_started.textile index e25dac22da..c129aeb2e1 100644 --- a/guides/source/getting_started.textile +++ b/guides/source/getting_started.textile @@ -13,8 +13,6 @@ endprologue. WARNING. This Guide is based on Rails 3.2. Some of the code shown here will not work in earlier versions of Rails. -WARNING: The Edge version of this guide is currently being re-worked. Please excuse us while we re-arrange the place. - h3. Guide Assumptions This guide is designed for beginners who want to get started with a Rails -- cgit v1.2.3 From fae4a263c9ac45beb83307371cadf31da6d59d71 Mon Sep 17 00:00:00 2001 From: Oscar Del Ben Date: Sat, 19 May 2012 10:34:42 -0700 Subject: Typo --- activerecord/lib/active_record/aggregations.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/activerecord/lib/active_record/aggregations.rb b/activerecord/lib/active_record/aggregations.rb index c7a329d74d..7eeb16f0e8 100644 --- a/activerecord/lib/active_record/aggregations.rb +++ b/activerecord/lib/active_record/aggregations.rb @@ -10,9 +10,9 @@ module ActiveRecord # Active Record implements aggregation through a macro-like class method called +composed_of+ # for representing attributes as value objects. It expresses relationships like "Account [is] # composed of Money [among other things]" or "Person [is] composed of [an] address". Each call - # to the macro adds a description of how the value objects are created from the attributes of - # the entity object (when the entity is initialized either as a new object or from finding an - # existing object) and how it can be turned back into attributes (when the entity is saved to + # to the macro adds a description of how the value objects are created from the attributes of + # the entity object (when the entity is initialized either as a new object or from finding an + # existing object) and how it can be turned back into attributes (when the entity is saved to # the database). # # class Customer < ActiveRecord::Base @@ -109,7 +109,7 @@ module ActiveRecord # It's also important to treat the value objects as immutable. Don't allow the Money object to have # its amount changed after creation. Create a new Money object with the new value instead. The # Money#exchange_to method is an example of this. It returns a new value object instead of changing - # its own values. Active Record won't persist value objects that have been changed through means + # its own values. Active Record wont persist value objects that have been changed through means # other than the writer method. # # The immutable requirement is enforced by Active Record by freezing any object assigned as a value -- cgit v1.2.3 From ba896d37e3b43ec19cf86b7a6452718d9077db20 Mon Sep 17 00:00:00 2001 From: Oscar Del Ben Date: Sat, 19 May 2012 10:53:52 -0700 Subject: Revert typo --- activerecord/lib/active_record/aggregations.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/activerecord/lib/active_record/aggregations.rb b/activerecord/lib/active_record/aggregations.rb index 7eeb16f0e8..6ad16bee2b 100644 --- a/activerecord/lib/active_record/aggregations.rb +++ b/activerecord/lib/active_record/aggregations.rb @@ -109,7 +109,7 @@ module ActiveRecord # It's also important to treat the value objects as immutable. Don't allow the Money object to have # its amount changed after creation. Create a new Money object with the new value instead. The # Money#exchange_to method is an example of this. It returns a new value object instead of changing - # its own values. Active Record wont persist value objects that have been changed through means + # its own values. Active Record won't persist value objects that have been changed through means # other than the writer method. # # The immutable requirement is enforced by Active Record by freezing any object assigned as a value -- cgit v1.2.3 From 952737af35be26ac4760efa3b06a0313ceae2c68 Mon Sep 17 00:00:00 2001 From: Francesco Rodriguez Date: Sat, 19 May 2012 14:58:19 -0500 Subject: add CollectionProxy#find documentation --- .../active_record/associations/collection_proxy.rb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/activerecord/lib/active_record/associations/collection_proxy.rb b/activerecord/lib/active_record/associations/collection_proxy.rb index fa316a8c9d..1c22309d99 100644 --- a/activerecord/lib/active_record/associations/collection_proxy.rb +++ b/activerecord/lib/active_record/associations/collection_proxy.rb @@ -36,6 +36,26 @@ module ActiveRecord class CollectionProxy < Relation delegate :target, :load_target, :loaded?, :to => :@association + ## + # :method: find + # Finds an object in the collection responding to the +id+. Uses the same + # rules as +ActiveRecord::Base.find+. Returns +ActiveRecord::RecordNotFound++ + # error if the object can not be found. + # + # class Person < ActiveRecord::Base + # has_many :pets + # end + # + # person.pets + # # => [ + # # #, + # # #, + # # # + # # ] + # + # person.pets.find(1) # => # + # person.pets.find(4) # => ActiveRecord::RecordNotFound: Couldn't find Pet with id=4 + ## # :method: first # Returns the first record, or the first +n+ records, from the collection. -- cgit v1.2.3 From a6940f2a8307320599ded0dbcedd2375b392eaec Mon Sep 17 00:00:00 2001 From: Francesco Rodriguez Date: Sat, 19 May 2012 16:18:59 -0500 Subject: add CollectionProxy#select documentation --- .../active_record/associations/collection_proxy.rb | 57 +++++++++++++++++++++- 1 file changed, 55 insertions(+), 2 deletions(-) diff --git a/activerecord/lib/active_record/associations/collection_proxy.rb b/activerecord/lib/active_record/associations/collection_proxy.rb index 1c22309d99..647d495d56 100644 --- a/activerecord/lib/active_record/associations/collection_proxy.rb +++ b/activerecord/lib/active_record/associations/collection_proxy.rb @@ -36,6 +36,59 @@ module ActiveRecord class CollectionProxy < Relation delegate :target, :load_target, :loaded?, :to => :@association + ## + # :method: select + # + # Works in two ways. + # + # *First:* Specify a subset of fields to be selected from the result set. + # + # class Person < ActiveRecord::Base + # has_many :pets + # end + # + # person.pets + # # => [ + # # #, + # # #, + # # # + # # ] + # + # person.pets.select(:name) + # # => [ + # # #, + # # #, + # # # + # # ] + # + # person.pets.select([:id, :name]) + # # => [ + # # #, + # # #, + # # # + # # ] + # + # Be careful because this also means you’re initializing a model + # object with only the fields that you’ve selected. If you attempt + # to access a field that is not in the initialized record you’ll + # receive: + # + # person.pets.select(:name).first.person_id + # # => ActiveModel::MissingAttributeError: missing attribute: person_id + # + # *Second:* You can pass a block so it can be used just like Array#select. + # This build an array of objects from the database for the scope, + # converting them into an array and iterating through them using + # Array#select. + # + # person.pets.select { |pet| pet.name =~ /oo/ } + # # => [ + # # #, + # # # + # # ] + # + # person.pets.select(:name) { |pet| pet.name =~ /oo/ } + ## # :method: find # Finds an object in the collection responding to the +id+. Uses the same @@ -51,7 +104,7 @@ module ActiveRecord # # #, # # #, # # # - # # ] + # # ] # # person.pets.find(1) # => # # person.pets.find(4) # => ActiveRecord::RecordNotFound: Couldn't find Pet with id=4 @@ -284,7 +337,7 @@ module ActiveRecord :sum, :count, :size, :length, :empty?, :any?, :many?, :include?, :to => :@association - + def initialize(association) @association = association super association.klass, association.klass.arel_table -- cgit v1.2.3 From 7eb09aed874dbb5f50a9ac0d0dec22e42f6161be Mon Sep 17 00:00:00 2001 From: Henrik Hodne Date: Sun, 20 May 2012 00:50:22 +0200 Subject: Update documentation for AbstractController::Base --- actionpack/lib/abstract_controller/base.rb | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/actionpack/lib/abstract_controller/base.rb b/actionpack/lib/abstract_controller/base.rb index 97a9eec144..32ec7ced0f 100644 --- a/actionpack/lib/abstract_controller/base.rb +++ b/actionpack/lib/abstract_controller/base.rb @@ -51,7 +51,7 @@ module AbstractController # to specify particular actions as hidden. # # ==== Returns - # * array - An array of method names that should not be considered actions. + # * Array - An array of method names that should not be considered actions. def hidden_actions [] end @@ -63,7 +63,7 @@ module AbstractController # itself. Finally, #hidden_actions are removed. # # ==== Returns - # * set - A set of all methods that should be considered actions. + # * Set - A set of all methods that should be considered actions. def action_methods @action_methods ||= begin # All public instance methods of this class, including ancestors @@ -92,11 +92,12 @@ module AbstractController # controller_path. # # ==== Returns - # * string + # * String def controller_path @controller_path ||= name.sub(/Controller$/, '').underscore unless anonymous? end + # Refresh the cached action_methods when a new action_method is added. def method_added(name) super clear_action_methods! @@ -130,6 +131,7 @@ module AbstractController self.class.controller_path end + # Delegates to the class' #action_methods def action_methods self.class.action_methods end @@ -141,6 +143,12 @@ module AbstractController # false and available_action?("foo") returns true because # available action consider actions that are also available # through other means, for example, implicit render ones. + # + # ==== Parameters + # * action_name - The name of an action to be tested + # + # ==== Returns + # * TrueClass, FalseClass def available_action?(action_name) method_for_action(action_name).present? end -- cgit v1.2.3 From fa6d921e11363e9b8c4bc10f7aed0b9faffdc33a Mon Sep 17 00:00:00 2001 From: Henrik Hodne Date: Sun, 20 May 2012 01:29:13 +0200 Subject: Remove blank trailing comments MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For future reference, this is the regex I used: ^\s*#\s*\n(?!\s*#). Replace with the first match, and voilà! Note that the regex matches a little bit too much, so you probably want to `git add -i .` and go through every single diff to check if it actually should be changed. --- Rakefile | 1 - actionmailer/lib/action_mailer/delivery_methods.rb | 1 - .../lib/rails/generators/mailer/templates/mailer.rb | 1 - actionpack/lib/abstract_controller/helpers.rb | 1 - actionpack/lib/action_controller/base.rb | 1 - actionpack/lib/action_controller/metal.rb | 2 -- actionpack/lib/action_controller/metal/helpers.rb | 1 - actionpack/lib/action_controller/metal/mime_responds.rb | 1 - actionpack/lib/action_controller/metal/responder.rb | 10 ---------- actionpack/lib/action_controller/metal/streaming.rb | 1 - actionpack/lib/action_dispatch/http/mime_negotiation.rb | 2 -- actionpack/lib/action_dispatch/middleware/reloader.rb | 1 - actionpack/lib/action_dispatch/routing.rb | 1 - actionpack/lib/action_dispatch/routing/mapper.rb | 1 - .../lib/action_dispatch/routing/polymorphic_routes.rb | 2 -- actionpack/lib/action_dispatch/routing/redirection.rb | 1 - actionpack/lib/action_dispatch/routing/route_set.rb | 1 - actionpack/lib/action_dispatch/routing/url_for.rb | 1 - .../lib/action_dispatch/testing/assertions/routing.rb | 1 - .../helpers/asset_tag_helpers/stylesheet_tag_helpers.rb | 1 - actionpack/lib/action_view/helpers/capture_helper.rb | 1 - actionpack/lib/action_view/helpers/form_helper.rb | 11 ----------- actionpack/lib/action_view/helpers/form_options_helper.rb | 3 --- actionpack/lib/action_view/helpers/form_tag_helper.rb | 3 --- actionpack/lib/action_view/helpers/number_helper.rb | 1 - actionpack/lib/action_view/helpers/output_safety_helper.rb | 1 - actionpack/lib/action_view/helpers/record_tag_helper.rb | 2 -- actionpack/lib/action_view/helpers/rendering_helper.rb | 1 - actionpack/lib/action_view/helpers/sanitize_helper.rb | 12 ------------ actionpack/lib/action_view/helpers/tags/select.rb | 1 - actionpack/lib/action_view/helpers/url_helper.rb | 1 - actionpack/lib/action_view/template/resolver.rb | 1 - activemodel/lib/active_model/attribute_methods.rb | 1 - activemodel/lib/active_model/callbacks.rb | 1 - activemodel/lib/active_model/conversion.rb | 1 - activemodel/lib/active_model/errors.rb | 1 - activemodel/lib/active_model/lint.rb | 2 -- activemodel/lib/active_model/mass_assignment_security.rb | 2 -- activemodel/lib/active_model/observing.rb | 2 -- activemodel/lib/active_model/serialization.rb | 1 - activemodel/lib/active_model/validations.rb | 2 -- activemodel/lib/active_model/validations/validates.rb | 1 - activemodel/lib/active_model/validator.rb | 2 -- activemodel/test/cases/validations/i18n_validation_test.rb | 1 - activerecord/lib/active_record/aggregations.rb | 2 -- activerecord/lib/active_record/associations/association.rb | 1 - activerecord/lib/active_record/callbacks.rb | 1 - .../connection_adapters/abstract/schema_definitions.rb | 1 - .../connection_adapters/abstract/schema_statements.rb | 1 - .../lib/active_record/connection_adapters/mysql_adapter.rb | 1 - .../active_record/connection_adapters/postgresql_adapter.rb | 1 - .../active_record/connection_adapters/sqlite3_adapter.rb | 1 - activerecord/lib/active_record/locking/optimistic.rb | 1 - activerecord/lib/active_record/model.rb | 1 - activerecord/lib/active_record/observer.rb | 1 - activerecord/lib/active_record/persistence.rb | 1 - activerecord/lib/active_record/reflection.rb | 6 ------ activerecord/lib/active_record/relation/calculations.rb | 1 - activerecord/lib/active_record/relation/finder_methods.rb | 1 - activerecord/lib/active_record/relation/query_methods.rb | 3 --- activerecord/lib/active_record/relation/spawn_methods.rb | 3 --- activerecord/lib/active_record/validations/uniqueness.rb | 1 - activerecord/test/cases/attribute_methods_test.rb | 1 - activerecord/test/cases/validations/i18n_validation_test.rb | 1 - activerecord/test/models/subject.rb | 1 - activesupport/lib/active_support/benchmarkable.rb | 1 - activesupport/lib/active_support/callbacks.rb | 1 - activesupport/lib/active_support/concern.rb | 1 - activesupport/lib/active_support/configurable.rb | 2 -- .../lib/active_support/core_ext/array/conversions.rb | 1 - activesupport/lib/active_support/core_ext/array/uniq_by.rb | 1 - activesupport/lib/active_support/core_ext/enumerable.rb | 2 -- activesupport/lib/active_support/core_ext/hash/except.rb | 1 - .../lib/active_support/core_ext/hash/indifferent_access.rb | 2 -- .../lib/active_support/core_ext/integer/inflections.rb | 2 -- .../lib/active_support/core_ext/kernel/reporting.rb | 2 -- .../lib/active_support/core_ext/module/anonymous.rb | 1 - .../lib/active_support/core_ext/module/delegation.rb | 1 - .../lib/active_support/core_ext/module/introspection.rb | 2 -- activesupport/lib/active_support/core_ext/object/blank.rb | 7 ------- .../lib/active_support/core_ext/object/duplicable.rb | 5 ----- .../lib/active_support/core_ext/object/with_options.rb | 1 - .../lib/active_support/core_ext/string/inflections.rb | 1 - .../lib/active_support/core_ext/string/output_safety.rb | 1 - activesupport/lib/active_support/file_update_checker.rb | 1 - .../lib/active_support/hash_with_indifferent_access.rb | 4 ---- activesupport/lib/active_support/inflector/methods.rb | 1 - activesupport/lib/active_support/lazy_load_hooks.rb | 1 - activesupport/lib/active_support/log_subscriber.rb | 1 - .../lib/active_support/log_subscriber/test_helper.rb | 2 -- activesupport/lib/active_support/message_encryptor.rb | 1 - activesupport/lib/active_support/notifications.rb | 1 - activesupport/lib/active_support/ordered_options.rb | 1 - activesupport/lib/active_support/string_inquirer.rb | 1 - activesupport/lib/active_support/time_with_zone.rb | 2 -- railties/lib/rails/application.rb | 1 - railties/lib/rails/configuration.rb | 1 - railties/lib/rails/engine/configuration.rb | 1 - railties/lib/rails/generators/active_model.rb | 1 - railties/lib/rails/generators/base.rb | 1 - railties/lib/rails/generators/named_base.rb | 1 - railties/lib/rails/generators/resource_helpers.rb | 2 -- railties/lib/rails/generators/test_case.rb | 13 ------------- railties/lib/rails/railtie.rb | 1 - railties/test/generators/shared_generator_tests.rb | 1 - 105 files changed, 192 deletions(-) diff --git a/Rakefile b/Rakefile index 21eb60bbe1..be42c81f1f 100644 --- a/Rakefile +++ b/Rakefile @@ -179,7 +179,6 @@ 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| diff --git a/actionmailer/lib/action_mailer/delivery_methods.rb b/actionmailer/lib/action_mailer/delivery_methods.rb index 3b38dbccc7..d2ec48b1ab 100644 --- a/actionmailer/lib/action_mailer/delivery_methods.rb +++ b/actionmailer/lib/action_mailer/delivery_methods.rb @@ -50,7 +50,6 @@ module ActionMailer # 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) diff --git a/actionmailer/lib/rails/generators/mailer/templates/mailer.rb b/actionmailer/lib/rails/generators/mailer/templates/mailer.rb index edcfb4233d..835fc9b148 100644 --- a/actionmailer/lib/rails/generators/mailer/templates/mailer.rb +++ b/actionmailer/lib/rails/generators/mailer/templates/mailer.rb @@ -7,7 +7,6 @@ class <%= class_name %> < ActionMailer::Base # with the following lookup: # # en.<%= file_path.tr("/",".") %>.<%= action %>.subject - # def <%= action %> @greeting = "Hi" diff --git a/actionpack/lib/abstract_controller/helpers.rb b/actionpack/lib/abstract_controller/helpers.rb index 4e0672d590..529f920e6c 100644 --- a/actionpack/lib/abstract_controller/helpers.rb +++ b/actionpack/lib/abstract_controller/helpers.rb @@ -90,7 +90,6 @@ module AbstractController # +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) diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb index 71425cd542..90058245f5 100644 --- a/actionpack/lib/action_controller/base.rb +++ b/actionpack/lib/action_controller/base.rb @@ -167,7 +167,6 @@ 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! diff --git a/actionpack/lib/action_controller/metal.rb b/actionpack/lib/action_controller/metal.rb index 92433ab462..720c0f2258 100644 --- a/actionpack/lib/action_controller/metal.rb +++ b/actionpack/lib/action_controller/metal.rb @@ -9,7 +9,6 @@ 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) @@ -97,7 +96,6 @@ module ActionController # # You can refer to the modules included in ActionController::Base to see # other features you can bring into your metal controller. - # class Metal < AbstractController::Base abstract! diff --git a/actionpack/lib/action_controller/metal/helpers.rb b/actionpack/lib/action_controller/metal/helpers.rb index 86d061e3b7..598bc6c5cb 100644 --- a/actionpack/lib/action_controller/metal/helpers.rb +++ b/actionpack/lib/action_controller/metal/helpers.rb @@ -47,7 +47,6 @@ module ActionController # # 23 Aug 11:30 | Carolina Railhawks Soccer Match # N/A | Carolina Railhaws Training Workshop - # module Helpers extend ActiveSupport::Concern diff --git a/actionpack/lib/action_controller/metal/mime_responds.rb b/actionpack/lib/action_controller/metal/mime_responds.rb index 0b800c3c62..d9fc777250 100644 --- a/actionpack/lib/action_controller/metal/mime_responds.rb +++ b/actionpack/lib/action_controller/metal/mime_responds.rb @@ -52,7 +52,6 @@ module ActionController #:nodoc: end # Clear all mime types in respond_to. - # def clear_respond_to self.mimes_for_respond_to = Hash.new.freeze end diff --git a/actionpack/lib/action_controller/metal/responder.rb b/actionpack/lib/action_controller/metal/responder.rb index 83407846dc..5aa3b2ca15 100644 --- a/actionpack/lib/action_controller/metal/responder.rb +++ b/actionpack/lib/action_controller/metal/responder.rb @@ -142,13 +142,11 @@ module ActionController #:nodoc: # 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 @@ -156,7 +154,6 @@ module ActionController #:nodoc: # HTML format does not render the resource, it always attempt to render a # template. - # def to_html default_render rescue ActionView::MissingTemplate => e @@ -171,7 +168,6 @@ module ActionController #:nodoc: # 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 @@ -209,14 +205,12 @@ module ActionController #:nodoc: 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 @@ -225,7 +219,6 @@ module ActionController #:nodoc: # If a response block was given, use it, otherwise call render on # controller. - # def default_render if @default_response @default_response.call(options) @@ -250,7 +243,6 @@ module ActionController #:nodoc: # Results in: # # render :xml => @user, :status => :created - # def display(resource, given_options={}) controller.render given_options.merge!(options).merge!(format => resource) end @@ -260,14 +252,12 @@ module ActionController #:nodoc: end # Check whether the resource has errors. - # def has_errors? resource.respond_to?(:errors) && !resource.errors.empty? end # By default, render the :edit action for HTML requests with errors, unless # the verb was POST. - # def default_action @action ||= DEFAULT_ACTIONS_FOR_VERBS[request.request_method_symbol] end diff --git a/actionpack/lib/action_controller/metal/streaming.rb b/actionpack/lib/action_controller/metal/streaming.rb index eeb37db2e7..0c3caa9514 100644 --- a/actionpack/lib/action_controller/metal/streaming.rb +++ b/actionpack/lib/action_controller/metal/streaming.rb @@ -194,7 +194,6 @@ module ActionController #:nodoc: # ==== Passenger # # To be described. - # module Streaming extend ActiveSupport::Concern diff --git a/actionpack/lib/action_dispatch/http/mime_negotiation.rb b/actionpack/lib/action_dispatch/http/mime_negotiation.rb index e31f3b823d..ca40ab9502 100644 --- a/actionpack/lib/action_dispatch/http/mime_negotiation.rb +++ b/actionpack/lib/action_dispatch/http/mime_negotiation.rb @@ -46,7 +46,6 @@ module ActionDispatch # 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 @@ -82,7 +81,6 @@ module ActionDispatch # 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 diff --git a/actionpack/lib/action_dispatch/middleware/reloader.rb b/actionpack/lib/action_dispatch/middleware/reloader.rb index 2f6968eb2e..23415dae54 100644 --- a/actionpack/lib/action_dispatch/middleware/reloader.rb +++ b/actionpack/lib/action_dispatch/middleware/reloader.rb @@ -22,7 +22,6 @@ module ActionDispatch # is false. Callbacks may be registered even when it is not included in the # middleware stack, but are executed only when ActionDispatch::Reloader.prepare! # or ActionDispatch::Reloader.cleanup! are called manually. - # class Reloader include ActiveSupport::Callbacks diff --git a/actionpack/lib/action_dispatch/routing.rb b/actionpack/lib/action_dispatch/routing.rb index 38a0270151..a2a6fb39dc 100644 --- a/actionpack/lib/action_dispatch/routing.rb +++ b/actionpack/lib/action_dispatch/routing.rb @@ -277,7 +277,6 @@ module ActionDispatch # rake routes # # Target specific controllers by prefixing the command with CONTROLLER=x. - # module Routing autoload :Mapper, 'action_dispatch/routing/mapper' autoload :RouteSet, 'action_dispatch/routing/route_set' diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index 67a208263b..79eee21619 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -897,7 +897,6 @@ module ActionDispatch # 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. diff --git a/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb b/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb index 8fde667108..817cdb2d4e 100644 --- a/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb +++ b/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb @@ -51,7 +51,6 @@ module ActionDispatch # # 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: @@ -84,7 +83,6 @@ module ActionDispatch # # # 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 diff --git a/actionpack/lib/action_dispatch/routing/redirection.rb b/actionpack/lib/action_dispatch/routing/redirection.rb index b3823bb496..d8beba4397 100644 --- a/actionpack/lib/action_dispatch/routing/redirection.rb +++ b/actionpack/lib/action_dispatch/routing/redirection.rb @@ -121,7 +121,6 @@ module ActionDispatch # a string. # # match 'accounts/:name' => redirect(SubdomainRedirector.new('api')) - # def redirect(*args, &block) options = args.extract_options! status = options.delete(:status) || 301 diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb index 0ae668d42a..c5601a82d6 100644 --- a/actionpack/lib/action_dispatch/routing/route_set.rb +++ b/actionpack/lib/action_dispatch/routing/route_set.rb @@ -180,7 +180,6 @@ module ActionDispatch # 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]) diff --git a/actionpack/lib/action_dispatch/routing/url_for.rb b/actionpack/lib/action_dispatch/routing/url_for.rb index fd3bed7e8f..207f56aaea 100644 --- a/actionpack/lib/action_dispatch/routing/url_for.rb +++ b/actionpack/lib/action_dispatch/routing/url_for.rb @@ -79,7 +79,6 @@ module ActionDispatch # end # # User.find(1).base_uri # => "/users/1" - # module UrlFor extend ActiveSupport::Concern include PolymorphicRoutes diff --git a/actionpack/lib/action_dispatch/testing/assertions/routing.rb b/actionpack/lib/action_dispatch/testing/assertions/routing.rb index 567ca0c392..1539b894c9 100644 --- a/actionpack/lib/action_dispatch/testing/assertions/routing.rb +++ b/actionpack/lib/action_dispatch/testing/assertions/routing.rb @@ -140,7 +140,6 @@ module ActionDispatch # end # end # end - # def with_routing old_routes, @routes = @routes, ActionDispatch::Routing::RouteSet.new if defined?(@controller) && @controller diff --git a/actionpack/lib/action_view/helpers/asset_tag_helpers/stylesheet_tag_helpers.rb b/actionpack/lib/action_view/helpers/asset_tag_helpers/stylesheet_tag_helpers.rb index 57b0627225..d7df9ea0d5 100644 --- a/actionpack/lib/action_view/helpers/asset_tag_helpers/stylesheet_tag_helpers.rb +++ b/actionpack/lib/action_view/helpers/asset_tag_helpers/stylesheet_tag_helpers.rb @@ -139,7 +139,6 @@ module ActionView # 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) diff --git a/actionpack/lib/action_view/helpers/capture_helper.rb b/actionpack/lib/action_view/helpers/capture_helper.rb index 397738dd98..c1f47a2eac 100644 --- a/actionpack/lib/action_view/helpers/capture_helper.rb +++ b/actionpack/lib/action_view/helpers/capture_helper.rb @@ -33,7 +33,6 @@ module ActionView # # <%= @greeting %> # - # def capture(*args) value = nil buffer = with_output_buffer { value = yield(*args) } diff --git a/actionpack/lib/action_view/helpers/form_helper.rb b/actionpack/lib/action_view/helpers/form_helper.rb index 6510610034..61e7a89585 100644 --- a/actionpack/lib/action_view/helpers/form_helper.rb +++ b/actionpack/lib/action_view/helpers/form_helper.rb @@ -763,7 +763,6 @@ module ActionView # # text_field(:snippet, :code, :size => 20, :class => 'code_input') # # => - # def text_field(object_name, method, options = {}) Tags::TextField.new(object_name, method, self, options).render end @@ -785,7 +784,6 @@ module ActionView # # password_field(:account, :pin, :size => 20, :class => 'form_input') # # => - # def password_field(object_name, method, options = {}) Tags::PasswordField.new(object_name, method, self, options).render end @@ -824,7 +822,6 @@ module ActionView # # file_field(:attachment, :file, :class => 'file_input') # # => - # def file_field(object_name, method, options = {}) Tags::FileField.new(object_name, method, self, options).render end @@ -913,7 +910,6 @@ module ActionView # check_box("eula", "accepted", { :class => 'eula_check' }, "yes", "no") # # => # # - # 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 @@ -966,7 +962,6 @@ module ActionView # # telephone_field("user", "phone") # # => - # def telephone_field(object_name, method, options = {}) Tags::TelField.new(object_name, method, self, options).render end @@ -985,7 +980,6 @@ module ActionView # @user.born_on = Date.new(1984, 1, 27) # date_field("user", "born_on", value: "1984-05-12") # # => - # def date_field(object_name, method, options = {}) Tags::DateField.new(object_name, method, self, options).render end @@ -1002,7 +996,6 @@ module ActionView # === Example # time_field("task", "started_at") # # => - # def time_field(object_name, method, options = {}) Tags::TimeField.new(object_name, method, self, options).render end @@ -1011,7 +1004,6 @@ module ActionView # # url_field("user", "homepage") # # => - # def url_field(object_name, method, options = {}) Tags::UrlField.new(object_name, method, self, options).render end @@ -1020,7 +1012,6 @@ module ActionView # # email_field("user", "address") # # => - # def email_field(object_name, method, options = {}) Tags::EmailField.new(object_name, method, self, options).render end @@ -1200,7 +1191,6 @@ module ActionView # submit: # post: # create: "Add %{model}" - # def submit(value=nil, options={}) value, options = nil, value if value.is_a?(Hash) value ||= submit_default_value @@ -1233,7 +1223,6 @@ module ActionView # submit: # post: # create: "Add %{model}" - # def button(value=nil, options={}) value, options = nil, value if value.is_a?(Hash) value ||= submit_default_value diff --git a/actionpack/lib/action_view/helpers/form_options_helper.rb b/actionpack/lib/action_view/helpers/form_options_helper.rb index eef426703d..90fa1f3520 100644 --- a/actionpack/lib/action_view/helpers/form_options_helper.rb +++ b/actionpack/lib/action_view/helpers/form_options_helper.rb @@ -98,7 +98,6 @@ module ActionView # # # - # module FormOptionsHelper # ERB::Util can mask some helpers like textilize. Make sure to include them. include TextHelper @@ -154,7 +153,6 @@ module ActionView # 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 :include_blank => false option. - # def select(object, method, choices, options = {}, html_options = {}) Tags::Select.new(object, method, self, choices, options, html_options).render end @@ -241,7 +239,6 @@ module ActionView # # # - # 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 diff --git a/actionpack/lib/action_view/helpers/form_tag_helper.rb b/actionpack/lib/action_view/helpers/form_tag_helper.rb index e65b4e3e95..07453c4b50 100644 --- a/actionpack/lib/action_view/helpers/form_tag_helper.rb +++ b/actionpack/lib/action_view/helpers/form_tag_helper.rb @@ -63,7 +63,6 @@ module ActionView # # 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? @@ -409,7 +408,6 @@ module ActionView # # submit_tag "Save", :confirm => "Are you sure?" # # => - # def submit_tag(value = "Save changes", options = {}) options = options.stringify_keys @@ -446,7 +444,6 @@ module ActionView # # => - # def button_tag(content_or_options = nil, options = nil, &block) options = content_or_options if block_given? && content_or_options.is_a?(Hash) options ||= {} diff --git a/actionpack/lib/action_view/helpers/number_helper.rb b/actionpack/lib/action_view/helpers/number_helper.rb index dfc26acfad..9e43a1faf1 100644 --- a/actionpack/lib/action_view/helpers/number_helper.rb +++ b/actionpack/lib/action_view/helpers/number_helper.rb @@ -514,7 +514,6 @@ module ActionView # 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 diff --git a/actionpack/lib/action_view/helpers/output_safety_helper.rb b/actionpack/lib/action_view/helpers/output_safety_helper.rb index 2e7e9dc50c..891dd859fa 100644 --- a/actionpack/lib/action_view/helpers/output_safety_helper.rb +++ b/actionpack/lib/action_view/helpers/output_safety_helper.rb @@ -26,7 +26,6 @@ module ActionView #:nodoc: # # safe_join(["

foo

".html_safe, "

bar

".html_safe], "
".html_safe) # # => "

foo


bar

" - # def safe_join(array, sep=$,) sep = ERB::Util.html_escape(sep) diff --git a/actionpack/lib/action_view/helpers/record_tag_helper.rb b/actionpack/lib/action_view/helpers/record_tag_helper.rb index 9b35f076e5..8734136f39 100644 --- a/actionpack/lib/action_view/helpers/record_tag_helper.rb +++ b/actionpack/lib/action_view/helpers/record_tag_helper.rb @@ -29,7 +29,6 @@ module ActionView # #
Joe Bloggs
#
Jane Bloggs
- # def div_for(record, *args, &block) content_tag_for(:div, record, *args, &block) end @@ -79,7 +78,6 @@ module ActionView # produces: # #
  • ... - # def content_tag_for(tag_name, single_or_multiple_records, prefix = nil, options = nil, &block) options, prefix = prefix, nil if prefix.is_a?(Hash) diff --git a/actionpack/lib/action_view/helpers/rendering_helper.rb b/actionpack/lib/action_view/helpers/rendering_helper.rb index 626e1a1ab7..55fb443929 100644 --- a/actionpack/lib/action_view/helpers/rendering_helper.rb +++ b/actionpack/lib/action_view/helpers/rendering_helper.rb @@ -75,7 +75,6 @@ module ActionView # # Hello David # - # def _layout_for(*args, &block) name = args.first diff --git a/actionpack/lib/action_view/helpers/sanitize_helper.rb b/actionpack/lib/action_view/helpers/sanitize_helper.rb index a727b910e5..ba74217c12 100644 --- a/actionpack/lib/action_view/helpers/sanitize_helper.rb +++ b/actionpack/lib/action_view/helpers/sanitize_helper.rb @@ -55,7 +55,6 @@ module ActionView # 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 @@ -144,7 +143,6 @@ module ActionView # class Application < Rails::Application # config.action_view.full_sanitizer = MySpecialSanitizer.new # end - # def full_sanitizer @full_sanitizer ||= HTML::FullSanitizer.new end @@ -155,7 +153,6 @@ module ActionView # class Application < Rails::Application # config.action_view.link_sanitizer = MySpecialSanitizer.new # end - # def link_sanitizer @link_sanitizer ||= HTML::LinkSanitizer.new end @@ -166,7 +163,6 @@ module ActionView # class Application < Rails::Application # config.action_view.white_list_sanitizer = MySpecialSanitizer.new # end - # def white_list_sanitizer @white_list_sanitizer ||= HTML::WhiteListSanitizer.new end @@ -176,7 +172,6 @@ module ActionView # 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 @@ -186,7 +181,6 @@ module ActionView # 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 @@ -196,7 +190,6 @@ module ActionView # 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 @@ -206,7 +199,6 @@ module ActionView # 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 @@ -216,7 +208,6 @@ module ActionView # 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 @@ -226,7 +217,6 @@ module ActionView # 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 @@ -236,7 +226,6 @@ module ActionView # 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 @@ -246,7 +235,6 @@ module ActionView # 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 diff --git a/actionpack/lib/action_view/helpers/tags/select.rb b/actionpack/lib/action_view/helpers/tags/select.rb index 53a108b7e6..4d94ee2c23 100644 --- a/actionpack/lib/action_view/helpers/tags/select.rb +++ b/actionpack/lib/action_view/helpers/tags/select.rb @@ -31,7 +31,6 @@ module ActionView # # [nil, []] # { nil => [] } - # def grouped_choices? !@choices.empty? && @choices.first.respond_to?(:last) && Array === @choices.first.last end diff --git a/actionpack/lib/action_view/helpers/url_helper.rb b/actionpack/lib/action_view/helpers/url_helper.rb index 7e69547dab..2e45a2ae0f 100644 --- a/actionpack/lib/action_view/helpers/url_helper.rb +++ b/actionpack/lib/action_view/helpers/url_helper.rb @@ -586,7 +586,6 @@ module ActionView # # current_page?(:controller => 'product', :action => 'index') # # => false - # def current_page?(options) unless request raise "You cannot use helpers that need to determine the current " \ diff --git a/actionpack/lib/action_view/template/resolver.rb b/actionpack/lib/action_view/template/resolver.rb index fa2038f78d..d267a8466a 100644 --- a/actionpack/lib/action_view/template/resolver.rb +++ b/actionpack/lib/action_view/template/resolver.rb @@ -215,7 +215,6 @@ module ActionView # * :locale - possible locale versions # * :formats - possible request formats (for example html, json, xml...) # * :handlers - 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) diff --git a/activemodel/lib/active_model/attribute_methods.rb b/activemodel/lib/active_model/attribute_methods.rb index 99918fdb96..61985e241b 100644 --- a/activemodel/lib/active_model/attribute_methods.rb +++ b/activemodel/lib/active_model/attribute_methods.rb @@ -53,7 +53,6 @@ module ActiveModel # hash value. # # Hash keys must be strings. - # module AttributeMethods extend ActiveSupport::Concern diff --git a/activemodel/lib/active_model/callbacks.rb b/activemodel/lib/active_model/callbacks.rb index ebb4b51aa3..50709e5ee1 100644 --- a/activemodel/lib/active_model/callbacks.rb +++ b/activemodel/lib/active_model/callbacks.rb @@ -83,7 +83,6 @@ module ActiveModel # # obj is the MyModel instance that the callback is being called on # end # end - # def define_model_callbacks(*callbacks) options = callbacks.extract_options! options = { diff --git a/activemodel/lib/active_model/conversion.rb b/activemodel/lib/active_model/conversion.rb index d7f30f0920..cea11c1a18 100644 --- a/activemodel/lib/active_model/conversion.rb +++ b/activemodel/lib/active_model/conversion.rb @@ -22,7 +22,6 @@ module ActiveModel # cm.to_key # => nil # cm.to_param # => nil # cm.to_partial_path # => "contact_messages/contact_message" - # module Conversion extend ActiveSupport::Concern diff --git a/activemodel/lib/active_model/errors.rb b/activemodel/lib/active_model/errors.rb index aba6618b56..7b311a50ff 100644 --- a/activemodel/lib/active_model/errors.rb +++ b/activemodel/lib/active_model/errors.rb @@ -317,7 +317,6 @@ module ActiveModel # * activemodel.errors.messages.blank # * errors.attributes.title.blank # * errors.messages.blank - # def generate_message(attribute, type = :invalid, options = {}) type = options.delete(:message) if options[:message].is_a?(Symbol) diff --git a/activemodel/lib/active_model/lint.rb b/activemodel/lib/active_model/lint.rb index 88b730626c..2c7f2a9334 100644 --- a/activemodel/lib/active_model/lint.rb +++ b/activemodel/lib/active_model/lint.rb @@ -52,7 +52,6 @@ module ActiveModel # # 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 @@ -74,7 +73,6 @@ module ActiveModel # # 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 diff --git a/activemodel/lib/active_model/mass_assignment_security.rb b/activemodel/lib/active_model/mass_assignment_security.rb index 893fbf92c3..50951b28d9 100644 --- a/activemodel/lib/active_model/mass_assignment_security.rb +++ b/activemodel/lib/active_model/mass_assignment_security.rb @@ -56,8 +56,6 @@ module ActiveModel # # You can specify your own sanitizer object eg. MySanitizer.new. # See ActiveModel::MassAssignmentSecurity::LoggerSanitizer 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 diff --git a/activemodel/lib/active_model/observing.rb b/activemodel/lib/active_model/observing.rb index f5ea285ccb..117c19c412 100644 --- a/activemodel/lib/active_model/observing.rb +++ b/activemodel/lib/active_model/observing.rb @@ -124,7 +124,6 @@ module ActiveModel # # 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 @@ -192,7 +191,6 @@ module ActiveModel # 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 diff --git a/activemodel/lib/active_model/serialization.rb b/activemodel/lib/active_model/serialization.rb index 6d8fd21814..5fabfb7219 100644 --- a/activemodel/lib/active_model/serialization.rb +++ b/activemodel/lib/active_model/serialization.rb @@ -115,7 +115,6 @@ module ActiveModel # @data[key] # end # end - # alias :read_attribute_for_serialization :send # Add associations specified via the :include option. diff --git a/activemodel/lib/active_model/validations.rb b/activemodel/lib/active_model/validations.rb index 611e9ffd55..019d4b22cf 100644 --- a/activemodel/lib/active_model/validations.rb +++ b/activemodel/lib/active_model/validations.rb @@ -38,7 +38,6 @@ module ActiveModel # Note that ActiveModel::Validations automatically adds an +errors+ method # to your instances initialized with a new ActiveModel::Errors object, so # there is no need for you to do this manually. - # module Validations extend ActiveSupport::Concern @@ -222,7 +221,6 @@ module ActiveModel # @data[key] # end # end - # alias :read_attribute_for_validation :send protected diff --git a/activemodel/lib/active_model/validations/validates.rb b/activemodel/lib/active_model/validations/validates.rb index d94c4e3f4f..b6a1cfcf41 100644 --- a/activemodel/lib/active_model/validations/validates.rb +++ b/activemodel/lib/active_model/validations/validates.rb @@ -77,7 +77,6 @@ module ActiveModel # 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) diff --git a/activemodel/lib/active_model/validator.rb b/activemodel/lib/active_model/validator.rb index 2953126c3c..de1a271dde 100644 --- a/activemodel/lib/active_model/validator.rb +++ b/activemodel/lib/active_model/validator.rb @@ -94,7 +94,6 @@ module ActiveModel #:nodoc: # # This setup method is only called when used with validation macros or the # class level validates_with method. - # class Validator attr_reader :options @@ -102,7 +101,6 @@ module ActiveModel #:nodoc: # # PresenceValidator.kind # => :presence # UniquenessValidator.kind # => :uniqueness - # def self.kind @kind ||= name.split('::').last.underscore.sub(/_validator$/, '').to_sym unless anonymous? end diff --git a/activemodel/test/cases/validations/i18n_validation_test.rb b/activemodel/test/cases/validations/i18n_validation_test.rb index 6b6aad3bd1..0ea9f5393d 100644 --- a/activemodel/test/cases/validations/i18n_validation_test.rb +++ b/activemodel/test/cases/validations/i18n_validation_test.rb @@ -65,7 +65,6 @@ class I18nValidationTest < ActiveModel::TestCase # 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", {}, {}], diff --git a/activerecord/lib/active_record/aggregations.rb b/activerecord/lib/active_record/aggregations.rb index 6ad16bee2b..e0392c5a48 100644 --- a/activerecord/lib/active_record/aggregations.rb +++ b/activerecord/lib/active_record/aggregations.rb @@ -166,7 +166,6 @@ module ActiveRecord # 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: # composed_of :address adds address and address=(new_address) methods. @@ -207,7 +206,6 @@ module ActiveRecord # :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) diff --git a/activerecord/lib/active_record/associations/association.rb b/activerecord/lib/active_record/associations/association.rb index e75003f261..57d602fd83 100644 --- a/activerecord/lib/active_record/associations/association.rb +++ b/activerecord/lib/active_record/associations/association.rb @@ -34,7 +34,6 @@ module ActiveRecord # Returns the name of the table of the related class: # # post.comments.aliased_table_name # => "comments" - # def aliased_table_name klass.table_name end diff --git a/activerecord/lib/active_record/callbacks.rb b/activerecord/lib/active_record/callbacks.rb index a050fabf35..fe18a5d5aa 100644 --- a/activerecord/lib/active_record/callbacks.rb +++ b/activerecord/lib/active_record/callbacks.rb @@ -229,7 +229,6 @@ 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 diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb index df78ba6c5a..95ab375951 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb @@ -339,7 +339,6 @@ module ActiveRecord # t.remove_index # t.remove_timestamps # end - # class Table def initialize(table_name, base) @table_name = table_name diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb index 62b0f51bb2..e2eb72fdd6 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb @@ -380,7 +380,6 @@ module ActiveRecord # 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}" diff --git a/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb b/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb index 0b6734b010..3d6ab72e07 100644 --- a/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb @@ -59,7 +59,6 @@ module ActiveRecord # * :sslcert - Necessary to use MySQL with an SSL connection. # * :sslcapath - Necessary to use MySQL with an SSL connection. # * :sslcipher - Necessary to use MySQL with an SSL connection. - # class MysqlAdapter < AbstractMysqlAdapter class Column < AbstractMysqlAdapter::Column #:nodoc: diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb index 14bc95abfe..ad7c4025cf 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb @@ -684,7 +684,6 @@ module ActiveRecord # -> 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) diff --git a/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb b/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb index d4ffa82b17..25ec88c9c5 100644 --- a/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb @@ -265,7 +265,6 @@ module ActiveRecord # # 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('|') diff --git a/activerecord/lib/active_record/locking/optimistic.rb b/activerecord/lib/active_record/locking/optimistic.rb index a3412582fa..604da5a4fd 100644 --- a/activerecord/lib/active_record/locking/optimistic.rb +++ b/activerecord/lib/active_record/locking/optimistic.rb @@ -46,7 +46,6 @@ module ActiveRecord # class Person < ActiveRecord::Base # self.locking_column = :lock_person # end - # module Optimistic extend ActiveSupport::Concern diff --git a/activerecord/lib/active_record/model.rb b/activerecord/lib/active_record/model.rb index 105d1e0e2b..5906a57828 100644 --- a/activerecord/lib/active_record/model.rb +++ b/activerecord/lib/active_record/model.rb @@ -7,7 +7,6 @@ module ActiveRecord # class Post # include ActiveRecord::Model # end - # module Model module ClassMethods #:nodoc: include ActiveSupport::Callbacks::ClassMethods diff --git a/activerecord/lib/active_record/observer.rb b/activerecord/lib/active_record/observer.rb index fdf17c003c..2467edcc53 100644 --- a/activerecord/lib/active_record/observer.rb +++ b/activerecord/lib/active_record/observer.rb @@ -87,7 +87,6 @@ module ActiveRecord # If by any chance you are using observed models in the initialization you can still # load their observers by calling ModelObserver.instance before. Observers are # singletons and that call instantiates and registers them. - # class Observer < ActiveModel::Observer protected diff --git a/activerecord/lib/active_record/persistence.rb b/activerecord/lib/active_record/persistence.rb index a1bc39a32d..daf5936a2d 100644 --- a/activerecord/lib/active_record/persistence.rb +++ b/activerecord/lib/active_record/persistence.rb @@ -158,7 +158,6 @@ module ActiveRecord # * 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) diff --git a/activerecord/lib/active_record/reflection.rb b/activerecord/lib/active_record/reflection.rb index c380b5c029..17e388a1d4 100644 --- a/activerecord/lib/active_record/reflection.rb +++ b/activerecord/lib/active_record/reflection.rb @@ -42,7 +42,6 @@ module ActiveRecord # 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) @@ -57,7 +56,6 @@ module ActiveRecord # # 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 @@ -67,7 +65,6 @@ module ActiveRecord # # 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) @@ -386,7 +383,6 @@ module ActiveRecord # 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 @@ -401,7 +397,6 @@ module ActiveRecord # # 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 @@ -488,7 +483,6 @@ module ActiveRecord # Gets an array of possible :through 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 diff --git a/activerecord/lib/active_record/relation/calculations.rb b/activerecord/lib/active_record/relation/calculations.rb index 31d99f0192..75d983d3b8 100644 --- a/activerecord/lib/active_record/relation/calculations.rb +++ b/activerecord/lib/active_record/relation/calculations.rb @@ -138,7 +138,6 @@ module ActiveRecord # 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}" diff --git a/activerecord/lib/active_record/relation/finder_methods.rb b/activerecord/lib/active_record/relation/finder_methods.rb index 4fedd33d64..9d62e726d4 100644 --- a/activerecord/lib/active_record/relation/finder_methods.rb +++ b/activerecord/lib/active_record/relation/finder_methods.rb @@ -49,7 +49,6 @@ module ActiveRecord # # Post.find_by name: 'Spartacus', rating: 4 # Post.find_by "published_at < ?", 2.weeks.ago - # def find_by(*args) where(*args).take end diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb index 19fe8155d9..c086386da6 100644 --- a/activerecord/lib/active_record/relation/query_methods.rb +++ b/activerecord/lib/active_record/relation/query_methods.rb @@ -163,7 +163,6 @@ module ActiveRecord # 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 @@ -277,7 +276,6 @@ module ActiveRecord # Post.none # => returning [] instead breaks the previous code # end # end - # def none NullRelation.new(@klass, @table) end @@ -312,7 +310,6 @@ module ActiveRecord # # 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 diff --git a/activerecord/lib/active_record/relation/spawn_methods.rb b/activerecord/lib/active_record/relation/spawn_methods.rb index 80d087a9ea..4fb1cb6726 100644 --- a/activerecord/lib/active_record/relation/spawn_methods.rb +++ b/activerecord/lib/active_record/relation/spawn_methods.rb @@ -23,7 +23,6 @@ module ActiveRecord # 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 @@ -45,7 +44,6 @@ module ActiveRecord # # 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 @@ -59,7 +57,6 @@ module ActiveRecord # # 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 diff --git a/activerecord/lib/active_record/validations/uniqueness.rb b/activerecord/lib/active_record/validations/uniqueness.rb index 9e4b588ac2..c1a72ea8b3 100644 --- a/activerecord/lib/active_record/validations/uniqueness.rb +++ b/activerecord/lib/active_record/validations/uniqueness.rb @@ -198,7 +198,6 @@ module ActiveRecord # * ActiveRecord::ConnectionAdapters::Mysql2Adapter # * ActiveRecord::ConnectionAdapters::SQLite3Adapter # * ActiveRecord::ConnectionAdapters::PostgreSQLAdapter - # def validates_uniqueness_of(*attr_names) validates_with UniquenessValidator, _merge_attributes(attr_names) end diff --git a/activerecord/test/cases/attribute_methods_test.rb b/activerecord/test/cases/attribute_methods_test.rb index 1093fedea1..eef1366a6d 100644 --- a/activerecord/test/cases/attribute_methods_test.rb +++ b/activerecord/test/cases/attribute_methods_test.rb @@ -719,7 +719,6 @@ class AttributeMethodsTest < ActiveRecord::TestCase 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 diff --git a/activerecord/test/cases/validations/i18n_validation_test.rb b/activerecord/test/cases/validations/i18n_validation_test.rb index 15b97c02c8..89b92e0b13 100644 --- a/activerecord/test/cases/validations/i18n_validation_test.rb +++ b/activerecord/test/cases/validations/i18n_validation_test.rb @@ -33,7 +33,6 @@ class I18nValidationTest < ActiveRecord::TestCase # 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", {}, {}], diff --git a/activerecord/test/models/subject.rb b/activerecord/test/models/subject.rb index 8e28f8b86b..6bf45ba5b2 100644 --- a/activerecord/test/models/subject.rb +++ b/activerecord/test/models/subject.rb @@ -1,5 +1,4 @@ # 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 diff --git a/activesupport/lib/active_support/benchmarkable.rb b/activesupport/lib/active_support/benchmarkable.rb index f149a7f0ed..a39fa016ec 100644 --- a/activesupport/lib/active_support/benchmarkable.rb +++ b/activesupport/lib/active_support/benchmarkable.rb @@ -44,7 +44,6 @@ module ActiveSupport end # Silence the logger during the execution of the block. - # def silence old_logger_level, logger.level = logger.level, ::Logger::ERROR if logger yield diff --git a/activesupport/lib/active_support/callbacks.rb b/activesupport/lib/active_support/callbacks.rb index a9253c186d..9636bbccb5 100644 --- a/activesupport/lib/active_support/callbacks.rb +++ b/activesupport/lib/active_support/callbacks.rb @@ -341,7 +341,6 @@ module ActiveSupport # 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 : {} diff --git a/activesupport/lib/active_support/concern.rb b/activesupport/lib/active_support/concern.rb index c94a8d99f4..9450d4ea88 100644 --- a/activesupport/lib/active_support/concern.rb +++ b/activesupport/lib/active_support/concern.rb @@ -94,7 +94,6 @@ 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", []) diff --git a/activesupport/lib/active_support/configurable.rb b/activesupport/lib/active_support/configurable.rb index a8aa53a80f..afd56cb7ce 100644 --- a/activesupport/lib/active_support/configurable.rb +++ b/activesupport/lib/active_support/configurable.rb @@ -48,7 +48,6 @@ module ActiveSupport # user = User.new # user.allowed_access = true # user.allowed_access # => true - # def config_accessor(*names) options = names.extract_options! @@ -79,7 +78,6 @@ module ActiveSupport # # user.config.allowed_access # => true # user.config.level # => 1 - # def config @_config ||= self.class.config.inheritable_copy end diff --git a/activesupport/lib/active_support/core_ext/array/conversions.rb b/activesupport/lib/active_support/core_ext/array/conversions.rb index 24aa28b895..193388a158 100644 --- a/activesupport/lib/active_support/core_ext/array/conversions.rb +++ b/activesupport/lib/active_support/core_ext/array/conversions.rb @@ -136,7 +136,6 @@ class Array # 1 # # - # def to_xml(options = {}) require 'active_support/builder' unless defined?(Builder) diff --git a/activesupport/lib/active_support/core_ext/array/uniq_by.rb b/activesupport/lib/active_support/core_ext/array/uniq_by.rb index 3bedfa9a61..c1d5a355a4 100644 --- a/activesupport/lib/active_support/core_ext/array/uniq_by.rb +++ b/activesupport/lib/active_support/core_ext/array/uniq_by.rb @@ -4,7 +4,6 @@ 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) diff --git a/activesupport/lib/active_support/core_ext/enumerable.rb b/activesupport/lib/active_support/core_ext/enumerable.rb index 02d5a7080f..b950826396 100644 --- a/activesupport/lib/active_support/core_ext/enumerable.rb +++ b/activesupport/lib/active_support/core_ext/enumerable.rb @@ -17,7 +17,6 @@ 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) @@ -32,7 +31,6 @@ module Enumerable # => { "nextangle" => , "chade-" => , ...} # people.index_by { |person| "#{person.first_name} #{person.last_name}" } # => { "Chade- Fowlersburg-e" => , "David Heinemeier Hansson" => , ...} - # def index_by if block_given? Hash[map { |elem| [yield(elem), elem] }] diff --git a/activesupport/lib/active_support/core_ext/hash/except.rb b/activesupport/lib/active_support/core_ext/hash/except.rb index 5a61906222..fafd4919b9 100644 --- a/activesupport/lib/active_support/core_ext/hash/except.rb +++ b/activesupport/lib/active_support/core_ext/hash/except.rb @@ -10,7 +10,6 @@ class Hash # # {:a => 1}.with_indifferent_access.except(:a) # => {} # {:a => 1}.with_indifferent_access.except('a') # => {} - # def except(*keys) dup.except!(*keys) end diff --git a/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb b/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb index 7d54c9fae6..c1f368d0eb 100644 --- a/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb +++ b/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb @@ -5,7 +5,6 @@ class Hash # Returns an ActiveSupport::HashWithIndifferentAccess out of its receiver: # # {:a => 1}.with_indifferent_access["a"] # => 1 - # def with_indifferent_access ActiveSupport::HashWithIndifferentAccess.new_from_hash_copying_default(self) end @@ -19,6 +18,5 @@ class Hash # # b = {:b => 1} # {:a => b}.with_indifferent_access["a"] # calls b.nested_under_indifferent_access - # alias nested_under_indifferent_access with_indifferent_access end diff --git a/activesupport/lib/active_support/core_ext/integer/inflections.rb b/activesupport/lib/active_support/core_ext/integer/inflections.rb index 1e30687166..56f2ed5985 100644 --- a/activesupport/lib/active_support/core_ext/integer/inflections.rb +++ b/activesupport/lib/active_support/core_ext/integer/inflections.rb @@ -10,7 +10,6 @@ class Integer # 1003.ordinalize # => "1003rd" # -11.ordinalize # => "-11th" # -1001.ordinalize # => "-1001st" - # def ordinalize ActiveSupport::Inflector.ordinalize(self) end @@ -24,7 +23,6 @@ class Integer # 1003.ordinal # => "rd" # -11.ordinal # => "th" # -1001.ordinal # => "st" - # def ordinal ActiveSupport::Inflector.ordinal(self) end diff --git a/activesupport/lib/active_support/core_ext/kernel/reporting.rb b/activesupport/lib/active_support/core_ext/kernel/reporting.rb index ad3f9ebec9..728069a9a8 100644 --- a/activesupport/lib/active_support/core_ext/kernel/reporting.rb +++ b/activesupport/lib/active_support/core_ext/kernel/reporting.rb @@ -65,7 +65,6 @@ module Kernel # # stream = capture(:stdout) { puts 'Cool' } # stream # => "Cool\n" - # def capture(stream) begin stream = stream.to_s @@ -83,7 +82,6 @@ module Kernel # Silences both STDOUT and STDERR, even for subprocesses. # # quietly { system 'bundle install' } - # def quietly silence_stream(STDOUT) do silence_stream(STDERR) do diff --git a/activesupport/lib/active_support/core_ext/module/anonymous.rb b/activesupport/lib/active_support/core_ext/module/anonymous.rb index 0a9e791030..b0c7b021db 100644 --- a/activesupport/lib/active_support/core_ext/module/anonymous.rb +++ b/activesupport/lib/active_support/core_ext/module/anonymous.rb @@ -13,7 +13,6 @@ 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 diff --git a/activesupport/lib/active_support/core_ext/module/delegation.rb b/activesupport/lib/active_support/core_ext/module/delegation.rb index fbef27c76a..30acc87c4a 100644 --- a/activesupport/lib/active_support/core_ext/module/delegation.rb +++ b/activesupport/lib/active_support/core_ext/module/delegation.rb @@ -100,7 +100,6 @@ class Module # end # # Foo.new.zoo # returns nil - # def delegate(*methods) options = methods.pop unless options.is_a?(Hash) && to = options[:to] diff --git a/activesupport/lib/active_support/core_ext/module/introspection.rb b/activesupport/lib/active_support/core_ext/module/introspection.rb index 3c8e811fa4..649a969149 100644 --- a/activesupport/lib/active_support/core_ext/module/introspection.rb +++ b/activesupport/lib/active_support/core_ext/module/introspection.rb @@ -27,7 +27,6 @@ class Module # # M.parent # => Object # Module.new.parent # => Object - # def parent parent_name ? ActiveSupport::Inflector.constantize(parent_name) : Object end @@ -44,7 +43,6 @@ class Module # M.parents # => [Object] # M::N.parents # => [M, Object] # X.parents # => [M, Object] - # def parents parents = [] if parent_name diff --git a/activesupport/lib/active_support/core_ext/object/blank.rb b/activesupport/lib/active_support/core_ext/object/blank.rb index e238fef5a2..09d9af1bde 100644 --- a/activesupport/lib/active_support/core_ext/object/blank.rb +++ b/activesupport/lib/active_support/core_ext/object/blank.rb @@ -43,7 +43,6 @@ class NilClass # +nil+ is blank: # # nil.blank? # => true - # def blank? true end @@ -53,7 +52,6 @@ class FalseClass # +false+ is blank: # # false.blank? # => true - # def blank? true end @@ -63,7 +61,6 @@ class TrueClass # +true+ is not blank: # # true.blank? # => false - # def blank? false end @@ -74,7 +71,6 @@ class Array # # [].blank? # => true # [1,2,3].blank? # => false - # alias_method :blank?, :empty? end @@ -83,7 +79,6 @@ class Hash # # {}.blank? # => true # {:key => 'value'}.blank? # => false - # alias_method :blank?, :empty? end @@ -94,7 +89,6 @@ class String # ' '.blank? # => true # ' '.blank? # => true # ' something here '.blank? # => false - # def blank? self !~ /[^[:space:]]/ end @@ -105,7 +99,6 @@ class Numeric #:nodoc: # # 1.blank? # => false # 0.blank? # => false - # def blank? false end diff --git a/activesupport/lib/active_support/core_ext/object/duplicable.rb b/activesupport/lib/active_support/core_ext/object/duplicable.rb index f1b755c2c4..9cd7485e2e 100644 --- a/activesupport/lib/active_support/core_ext/object/duplicable.rb +++ b/activesupport/lib/active_support/core_ext/object/duplicable.rb @@ -31,7 +31,6 @@ class NilClass # # nil.duplicable? # => false # nil.dup # => TypeError: can't dup NilClass - # def duplicable? false end @@ -42,7 +41,6 @@ class FalseClass # # false.duplicable? # => false # false.dup # => TypeError: can't dup FalseClass - # def duplicable? false end @@ -53,7 +51,6 @@ class TrueClass # # true.duplicable? # => false # true.dup # => TypeError: can't dup TrueClass - # def duplicable? false end @@ -64,7 +61,6 @@ class Symbol # # :my_symbol.duplicable? # => false # :my_symbol.dup # => TypeError: can't dup Symbol - # def duplicable? false end @@ -75,7 +71,6 @@ class Numeric # # 3.duplicable? # => false # 3.dup # => TypeError: can't dup Fixnum - # def duplicable? false end diff --git a/activesupport/lib/active_support/core_ext/object/with_options.rb b/activesupport/lib/active_support/core_ext/object/with_options.rb index e058367111..723bf69189 100644 --- a/activesupport/lib/active_support/core_ext/object/with_options.rb +++ b/activesupport/lib/active_support/core_ext/object/with_options.rb @@ -36,7 +36,6 @@ class Object # # with_options 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 diff --git a/activesupport/lib/active_support/core_ext/string/inflections.rb b/activesupport/lib/active_support/core_ext/string/inflections.rb index 070bfd7af6..e726a475e0 100644 --- a/activesupport/lib/active_support/core_ext/string/inflections.rb +++ b/activesupport/lib/active_support/core_ext/string/inflections.rb @@ -5,7 +5,6 @@ require 'active_support/inflector/transliterate' # 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. # diff --git a/activesupport/lib/active_support/core_ext/string/output_safety.rb b/activesupport/lib/active_support/core_ext/string/output_safety.rb index 5226ff0cbe..d4e1597840 100644 --- a/activesupport/lib/active_support/core_ext/string/output_safety.rb +++ b/activesupport/lib/active_support/core_ext/string/output_safety.rb @@ -64,7 +64,6 @@ class ERB # 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 diff --git a/activesupport/lib/active_support/file_update_checker.rb b/activesupport/lib/active_support/file_update_checker.rb index 8860636168..20dde73abf 100644 --- a/activesupport/lib/active_support/file_update_checker.rb +++ b/activesupport/lib/active_support/file_update_checker.rb @@ -28,7 +28,6 @@ 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 diff --git a/activesupport/lib/active_support/hash_with_indifferent_access.rb b/activesupport/lib/active_support/hash_with_indifferent_access.rb index 91459f3e5b..3191a3bdc6 100644 --- a/activesupport/lib/active_support/hash_with_indifferent_access.rb +++ b/activesupport/lib/active_support/hash_with_indifferent_access.rb @@ -53,7 +53,6 @@ module ActiveSupport # # hash = HashWithIndifferentAccess.new # hash[:key] = "value" - # def []=(key, value) regular_writer(convert_key(key), convert_value(value)) end @@ -69,7 +68,6 @@ module ActiveSupport # 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) @@ -87,7 +85,6 @@ module ActiveSupport # hash["key"] = "value" # hash.key? :key # => true # hash.key? "key" # => true - # def key?(key) super(convert_key(key)) end @@ -107,7 +104,6 @@ module ActiveSupport # 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 diff --git a/activesupport/lib/active_support/inflector/methods.rb b/activesupport/lib/active_support/inflector/methods.rb index 48296841aa..53a1c3f160 100644 --- a/activesupport/lib/active_support/inflector/methods.rb +++ b/activesupport/lib/active_support/inflector/methods.rb @@ -228,7 +228,6 @@ module ActiveSupport # "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) diff --git a/activesupport/lib/active_support/lazy_load_hooks.rb b/activesupport/lib/active_support/lazy_load_hooks.rb index c167efc1a7..34450c65d4 100644 --- a/activesupport/lib/active_support/lazy_load_hooks.rb +++ b/activesupport/lib/active_support/lazy_load_hooks.rb @@ -17,7 +17,6 @@ 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] = [] } diff --git a/activesupport/lib/active_support/log_subscriber.rb b/activesupport/lib/active_support/log_subscriber.rb index d2a6e1bd82..20ca6ff5f6 100644 --- a/activesupport/lib/active_support/log_subscriber.rb +++ b/activesupport/lib/active_support/log_subscriber.rb @@ -111,7 +111,6 @@ module ActiveSupport # 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) diff --git a/activesupport/lib/active_support/log_subscriber/test_helper.rb b/activesupport/lib/active_support/log_subscriber/test_helper.rb index b65ea6208c..5c7a238934 100644 --- a/activesupport/lib/active_support/log_subscriber/test_helper.rb +++ b/activesupport/lib/active_support/log_subscriber/test_helper.rb @@ -31,7 +31,6 @@ module ActiveSupport # 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 @@ -96,7 +95,6 @@ module ActiveSupport # def logger # ActiveRecord::Base.logger = @logger # end - # def set_logger(logger) ActiveSupport::LogSubscriber.logger = logger end diff --git a/activesupport/lib/active_support/message_encryptor.rb b/activesupport/lib/active_support/message_encryptor.rb index ada2e79ccb..c002b1c02c 100644 --- a/activesupport/lib/active_support/message_encryptor.rb +++ b/activesupport/lib/active_support/message_encryptor.rb @@ -36,7 +36,6 @@ module ActiveSupport # Options: # * :cipher - Cipher to use. Can be any cipher returned by OpenSSL::Cipher.ciphers. Default is 'aes-256-cbc' # * :serializer - Object serializer to use. Default is +Marshal+. - # def initialize(secret, options = {}) @secret = secret @cipher = options[:cipher] || 'aes-256-cbc' diff --git a/activesupport/lib/active_support/notifications.rb b/activesupport/lib/active_support/notifications.rb index 6735c561d3..6d89307638 100644 --- a/activesupport/lib/active_support/notifications.rb +++ b/activesupport/lib/active_support/notifications.rb @@ -133,7 +133,6 @@ 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) } diff --git a/activesupport/lib/active_support/ordered_options.rb b/activesupport/lib/active_support/ordered_options.rb index 60e6cd55ad..6bd6f1f2ff 100644 --- a/activesupport/lib/active_support/ordered_options.rb +++ b/activesupport/lib/active_support/ordered_options.rb @@ -13,7 +13,6 @@ # h.girl = 'Mary' # h.boy # => 'John' # h.girl # => 'Mary' -# module ActiveSupport #:nodoc: class OrderedOptions < Hash alias_method :_get, :[] # preserve the original #[] method diff --git a/activesupport/lib/active_support/string_inquirer.rb b/activesupport/lib/active_support/string_inquirer.rb index f3f3909a90..e059594bfa 100644 --- a/activesupport/lib/active_support/string_inquirer.rb +++ b/activesupport/lib/active_support/string_inquirer.rb @@ -8,7 +8,6 @@ module ActiveSupport # you can call this: # # Rails.env.production? - # class StringInquirer < String def method_missing(method_name, *arguments) if method_name[-1, 1] == "?" diff --git a/activesupport/lib/active_support/time_with_zone.rb b/activesupport/lib/active_support/time_with_zone.rb index 451520ac5c..f040ee7101 100644 --- a/activesupport/lib/active_support/time_with_zone.rb +++ b/activesupport/lib/active_support/time_with_zone.rb @@ -31,7 +31,6 @@ 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 @@ -127,7 +126,6 @@ module ActiveSupport # # 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 diff --git a/railties/lib/rails/application.rb b/railties/lib/rails/application.rb index c4edbae55b..6cd2c425c3 100644 --- a/railties/lib/rails/application.rb +++ b/railties/lib/rails/application.rb @@ -48,7 +48,6 @@ 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' diff --git a/railties/lib/rails/configuration.rb b/railties/lib/rails/configuration.rb index 3d66019e5e..57168eee83 100644 --- a/railties/lib/rails/configuration.rb +++ b/railties/lib/rails/configuration.rb @@ -32,7 +32,6 @@ module Rails # And finally they can also be removed from the stack completely: # # config.middleware.delete ActionDispatch::BestStandardsSupport - # class MiddlewareStackProxy def initialize @operations = [] diff --git a/railties/lib/rails/engine/configuration.rb b/railties/lib/rails/engine/configuration.rb index d3b42021fc..f4de5a4375 100644 --- a/railties/lib/rails/engine/configuration.rb +++ b/railties/lib/rails/engine/configuration.rb @@ -28,7 +28,6 @@ module Rails # 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? diff --git a/railties/lib/rails/generators/active_model.rb b/railties/lib/rails/generators/active_model.rb index 454327f765..3d3b50540a 100644 --- a/railties/lib/rails/generators/active_model.rb +++ b/railties/lib/rails/generators/active_model.rb @@ -22,7 +22,6 @@ module Rails # # The only exception in ActiveModel for ActiveRecord is the use of self.build # instead of self.new. - # class ActiveModel attr_reader :name diff --git a/railties/lib/rails/generators/base.rb b/railties/lib/rails/generators/base.rb index 28d7680669..f2ded6be84 100644 --- a/railties/lib/rails/generators/base.rb +++ b/railties/lib/rails/generators/base.rb @@ -161,7 +161,6 @@ module Rails # 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 diff --git a/railties/lib/rails/generators/named_base.rb b/railties/lib/rails/generators/named_base.rb index e85d1b8fa2..e02f19508f 100644 --- a/railties/lib/rails/generators/named_base.rb +++ b/railties/lib/rails/generators/named_base.rb @@ -168,7 +168,6 @@ module Rails # # 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 diff --git a/railties/lib/rails/generators/resource_helpers.rb b/railties/lib/rails/generators/resource_helpers.rb index 48833869e5..3c12da359b 100644 --- a/railties/lib/rails/generators/resource_helpers.rb +++ b/railties/lib/rails/generators/resource_helpers.rb @@ -4,7 +4,6 @@ module Rails module Generators # Deal with controller names on scaffold and add some helpers to deal with # ActiveModel. - # module ResourceHelpers mattr_accessor :skip_warn @@ -13,7 +12,6 @@ module Rails end # Set controller variables on initialization. - # def initialize(*args) #:nodoc: super diff --git a/railties/lib/rails/generators/test_case.rb b/railties/lib/rails/generators/test_case.rb index ff9cf0087e..e8f5925ca5 100644 --- a/railties/lib/rails/generators/test_case.rb +++ b/railties/lib/rails/generators/test_case.rb @@ -26,7 +26,6 @@ module Rails # destination File.expand_path("../tmp", File.dirname(__FILE__)) # setup :prepare_destination # end - # class TestCase < ActiveSupport::TestCase include FileUtils @@ -43,7 +42,6 @@ module Rails # Sets which generator should be tested: # # tests AppGenerator - # def self.tests(klass) self.generator_class = klass end @@ -52,7 +50,6 @@ module Rails # invoking it. # # arguments %w(app_name --skip-active-record) - # def self.arguments(array) self.default_arguments = array end @@ -60,7 +57,6 @@ module Rails # Sets the destination of generator files: # # destination File.expand_path("../tmp", File.dirname(__FILE__)) - # def self.destination(path) self.destination_root = path end @@ -83,7 +79,6 @@ module Rails # assert_match(/Product\.all/, index) # end # end - # def assert_file(relative, *contents) absolute = File.expand_path(relative, destination_root) assert File.exists?(absolute), "Expected file #{relative.inspect} to exist, but does not" @@ -106,7 +101,6 @@ module Rails # path relative to the configured destination: # # assert_no_file "config/random.rb" - # def assert_no_file(relative) absolute = File.expand_path(relative, destination_root) assert !File.exists?(absolute), "Expected file #{relative.inspect} to not exist, but does" @@ -124,7 +118,6 @@ module Rails # assert_file "db/migrate/003_create_products.rb" # # Consequently, assert_migration accepts the same arguments has assert_file. - # def assert_migration(relative, *contents, &block) file_name = migration_file_name(relative) assert file_name, "Expected migration #{relative} to exist, but was not found" @@ -135,7 +128,6 @@ module Rails # path relative to the configured destination: # # assert_no_migration "db/migrate/create_products.rb" - # def assert_no_migration(relative) file_name = migration_file_name(relative) assert_nil file_name, "Expected migration #{relative} to not exist, but found #{file_name}" @@ -150,7 +142,6 @@ module Rails # assert_match(/create_table/, up) # end # end - # def assert_class_method(method, content, &block) assert_instance_method "self.#{method}", content, &block end @@ -163,7 +154,6 @@ module Rails # assert_match(/Product\.all/, index) # end # end - # def assert_instance_method(method, content) assert content =~ /def #{method}(\(.+\))?(.*?)\n end/m, "Expected to have method #{method}" yield $2.strip if block_given? @@ -174,7 +164,6 @@ module Rails # properly: # # assert_field_type :date, :date_select - # def assert_field_type(attribute_type, field_type) assert_equal(field_type, create_generated_attribute(attribute_type).field_type) end @@ -182,7 +171,6 @@ module Rails # Asserts the given attribute type gets a proper default value: # # assert_field_default_value :string, "MyString" - # def assert_field_default_value(attribute_type, value) assert_equal(value, create_generated_attribute(attribute_type).default) end @@ -216,7 +204,6 @@ module Rails # attribute type and, optionally, the attribute name: # # create_generated_attribute(:string, 'name') - # def create_generated_attribute(attribute_type, name = 'test', index = nil) Rails::Generators::GeneratedAttribute.parse([name, attribute_type, index].compact.join(':')) end diff --git a/railties/lib/rails/railtie.rb b/railties/lib/rails/railtie.rb index 2102f8a03c..8fbf58315a 100644 --- a/railties/lib/rails/railtie.rb +++ b/railties/lib/rails/railtie.rb @@ -110,7 +110,6 @@ module Rails # can be used in both. # # Be sure to look at the documentation of those specific classes for more information. - # class Railtie autoload :Configurable, "rails/railtie/configurable" autoload :Configuration, "rails/railtie/configuration" diff --git a/railties/test/generators/shared_generator_tests.rb b/railties/test/generators/shared_generator_tests.rb index e78e67725d..6dc72f0fc0 100644 --- a/railties/test/generators/shared_generator_tests.rb +++ b/railties/test/generators/shared_generator_tests.rb @@ -1,6 +1,5 @@ # # Tests, setup, and teardown common to the application and plugin generator suites. -# module SharedGeneratorTests def setup Rails.application = TestApp::Application -- cgit v1.2.3 From 03402d206ae1d1977e5283173ecb43a88aacead0 Mon Sep 17 00:00:00 2001 From: Francesco Rodriguez Date: Sun, 20 May 2012 16:11:52 -0500 Subject: update CollectionProxy#destroy_all documentation --- .../lib/active_record/associations/collection_proxy.rb | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/activerecord/lib/active_record/associations/collection_proxy.rb b/activerecord/lib/active_record/associations/collection_proxy.rb index 647d495d56..21c5e3fc5a 100644 --- a/activerecord/lib/active_record/associations/collection_proxy.rb +++ b/activerecord/lib/active_record/associations/collection_proxy.rb @@ -221,18 +221,26 @@ module ActiveRecord ## # :method: destroy_all - # Destroy all the records from this association. + # Deletes the records of the collection directly from the database. # # class Person < ActiveRecord::Base # has_many :pets # end # # person.pets.size # => 3 + # person.pets + # # => [ + # # #, + # # #, + # # # + # # ] # # person.pets.destroy_all # # person.pets.size # => 0 # person.pets # => [] + # + # Pet.find(1) # => Couldn't find Pet with id=1 ## # :method: empty? -- cgit v1.2.3 From d83173483d397df8cdff913d9a4929684c7bd4ce Mon Sep 17 00:00:00 2001 From: Francesco Rodriguez Date: Mon, 21 May 2012 10:16:43 -0500 Subject: add CollectionProxy#destroy documentation --- .../active_record/associations/collection_proxy.rb | 43 +++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/activerecord/lib/active_record/associations/collection_proxy.rb b/activerecord/lib/active_record/associations/collection_proxy.rb index 21c5e3fc5a..a3797e9d59 100644 --- a/activerecord/lib/active_record/associations/collection_proxy.rb +++ b/activerecord/lib/active_record/associations/collection_proxy.rb @@ -222,6 +222,8 @@ module ActiveRecord ## # :method: destroy_all # Deletes the records of the collection directly from the database. + # This will _always_ remove the records ignoring the +:dependent+ + # option. # # class Person < ActiveRecord::Base # has_many :pets @@ -242,6 +244,45 @@ module ActiveRecord # # Pet.find(1) # => Couldn't find Pet with id=1 + ## + # :method: destroy + # Destroy the +records+ supplied and remove them from the collection. + # This method will _always_ remove record from the database ignoring + # the +:dependent+ option. Returns an array with the deleted records. + # + # class Person < ActiveRecord::Base + # has_many :pets + # end + # + # person.pets.size # => 3 + # person.pets + # # => [ + # # #, + # # #, + # # # + # # ] + # + # person.pets.destroy(Pet.find(1)) + # # => [#] + # + # person.pets.size # => 2 + # person.pets + # # => [ + # # #, + # # # + # # ] + # + # person.pets.destroy(Pet.find(2), Pet.find(3)) + # # => [ + # # #, + # # # + # # ] + # + # person.pets.size # => 0 + # person.pets # => [] + # + # Pet.find([1, 2, 3]) # => ActiveRecord::RecordNotFound: Couldn't find all Pets with IDs (1, 2, 3) + ## # :method: empty? # Returns true if the collection is empty. @@ -257,7 +298,7 @@ module ActiveRecord # # person.pets.count # => 0 # person.pets.empty? # => true - + ## # :method: any? # Returns true if the collection is not empty. -- cgit v1.2.3 From 1f5c1a14236b2df638d20bcf1617110c47a4bfe8 Mon Sep 17 00:00:00 2001 From: Francesco Rodriguez Date: Mon, 21 May 2012 11:56:00 -0500 Subject: improve CollectionProxy#destroy documentation --- .../active_record/associations/collection_proxy.rb | 42 +++++++++++++++++++--- 1 file changed, 37 insertions(+), 5 deletions(-) diff --git a/activerecord/lib/active_record/associations/collection_proxy.rb b/activerecord/lib/active_record/associations/collection_proxy.rb index a3797e9d59..e3ebe03121 100644 --- a/activerecord/lib/active_record/associations/collection_proxy.rb +++ b/activerecord/lib/active_record/associations/collection_proxy.rb @@ -248,7 +248,7 @@ module ActiveRecord # :method: destroy # Destroy the +records+ supplied and remove them from the collection. # This method will _always_ remove record from the database ignoring - # the +:dependent+ option. Returns an array with the deleted records. + # the +:dependent+ option. Returns an array with the removed records. # # class Person < ActiveRecord::Base # has_many :pets @@ -278,10 +278,42 @@ module ActiveRecord # # # # # ] # - # person.pets.size # => 0 - # person.pets # => [] + # person.pets.size # => 0 + # person.pets # => [] # - # Pet.find([1, 2, 3]) # => ActiveRecord::RecordNotFound: Couldn't find all Pets with IDs (1, 2, 3) + # Pet.find(1, 2, 3) # => ActiveRecord::RecordNotFound: Couldn't find all Pets with IDs (1, 2, 3) + # + # You can pass +Fixnum+ or +String+ values, it finds the records + # responding to the +id+ and then deletes them from the database. + # + # person.pets.size # => 3 + # person.pets + # # => [ + # # #, + # # #, + # # # + # # ] + # + # person.pets.destroy("4") + # # => # + # + # person.pets.size # => 2 + # person.pets + # # => [ + # # #, + # # # + # # ] + # + # person.pets.destroy(5, 6) + # # => [ + # # #, + # # # + # # ] + # + # person.pets.size # => 0 + # person.pets # => [] + # + # Pet.find(4, 5, 6) # => ActiveRecord::RecordNotFound: Couldn't find all Pets with IDs (4, 5, 6) ## # :method: empty? @@ -298,7 +330,7 @@ module ActiveRecord # # person.pets.count # => 0 # person.pets.empty? # => true - + ## # :method: any? # Returns true if the collection is not empty. -- cgit v1.2.3 From 158a71b2cbd6be9ef9c88282b48a3e39e47908ed Mon Sep 17 00:00:00 2001 From: Francesco Rodriguez Date: Mon, 21 May 2012 12:19:34 -0500 Subject: add CollectionProxy#reload documentation --- .../lib/active_record/associations/collection_proxy.rb | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/activerecord/lib/active_record/associations/collection_proxy.rb b/activerecord/lib/active_record/associations/collection_proxy.rb index e3ebe03121..80a1715ee2 100644 --- a/activerecord/lib/active_record/associations/collection_proxy.rb +++ b/activerecord/lib/active_record/associations/collection_proxy.rb @@ -516,6 +516,24 @@ module ActiveRecord self end + # Reloads the collection from the database. Returns +self+. + # Equivalent to +collection(true)+. + # + # class Person < ActiveRecord::Base + # has_many :pets + # end + # + # person.pets # fetches pets from the database + # # => [#] + # + # person.pets # uses the pets cache + # # => [#] + # + # person.pets.reload # fetches pets from the database + # # => [#] + # + # person.pets(true)  # fetches pets from the database + # # => [#] def reload proxy_association.reload self -- cgit v1.2.3 From ab2e2a9d2b772cf4aef4d9f4f2d506a03c205035 Mon Sep 17 00:00:00 2001 From: Francesco Rodriguez Date: Mon, 21 May 2012 12:26:04 -0500 Subject: fix CollectionProxy documentation markup --- .../lib/active_record/associations/collection_proxy.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/activerecord/lib/active_record/associations/collection_proxy.rb b/activerecord/lib/active_record/associations/collection_proxy.rb index 80a1715ee2..b419b9a749 100644 --- a/activerecord/lib/active_record/associations/collection_proxy.rb +++ b/activerecord/lib/active_record/associations/collection_proxy.rb @@ -112,7 +112,7 @@ module ActiveRecord ## # :method: first # Returns the first record, or the first +n+ records, from the collection. - # If the collection is empty, the first form returns nil, and the second + # If the collection is empty, the first form returns +nil+, and the second # form returns an empty array. # # class Person < ActiveRecord::Base @@ -141,7 +141,7 @@ module ActiveRecord ## # :method: last # Returns the last record, or the last +n+ records, from the collection. - # If the collection is empty, the first form returns nil, and the second + # If the collection is empty, the first form returns +nil+, and the second # form returns an empty array. # # class Person < ActiveRecord::Base @@ -317,7 +317,7 @@ module ActiveRecord ## # :method: empty? - # Returns true if the collection is empty. + # Returns +true+ if the collection is empty. # # class Person < ActiveRecord::Base # has_many :pets @@ -333,7 +333,7 @@ module ActiveRecord ## # :method: any? - # Returns true if the collection is not empty. + # Returns +true+ if the collection is not empty. # # class Person < ActiveRecord::Base # has_many :pets @@ -366,7 +366,7 @@ module ActiveRecord ## # :method: many? # Returns true if the collection has more than one record. - # Equivalent to +collection.size > 1+. + # Equivalent to collection.size > 1. # # class Person < ActiveRecord::Base # has_many :pets @@ -402,7 +402,7 @@ module ActiveRecord ## # :method: include? - # Returns true if the given object is present in the collection. + # Returns +true+ if the given object is present in the collection. # # class Person < ActiveRecord::Base # has_many :pets @@ -499,7 +499,7 @@ module ActiveRecord # # Pet.find(1) # => # # - # If they are associated with +dependent: :destroy+ option, it deletes + # If they are associated with dependent: :destroy option, it deletes # them directly from the database. # # class Person < ActiveRecord::Base @@ -517,7 +517,7 @@ module ActiveRecord end # Reloads the collection from the database. Returns +self+. - # Equivalent to +collection(true)+. + # Equivalent to collection(true). # # class Person < ActiveRecord::Base # has_many :pets -- cgit v1.2.3 From 5b7b705d36c58508e7da0a87dd6232f699653969 Mon Sep 17 00:00:00 2001 From: Alexey Vakhov Date: Tue, 22 May 2012 01:37:03 +0400 Subject: Fix AR preloader example --- activerecord/lib/active_record/associations/preloader.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/activerecord/lib/active_record/associations/preloader.rb b/activerecord/lib/active_record/associations/preloader.rb index fafed94ff2..54705e4950 100644 --- a/activerecord/lib/active_record/associations/preloader.rb +++ b/activerecord/lib/active_record/associations/preloader.rb @@ -12,7 +12,7 @@ module ActiveRecord # and all of its books via a single query: # # SELECT * FROM authors - # LEFT OUTER JOIN books ON authors.id = books.id + # LEFT OUTER JOIN books ON authors.id = books.author_id # WHERE authors.name = 'Ken Akamatsu' # # However, this could result in many rows that contain redundant data. After -- cgit v1.2.3 From f9a718eb5e3fe969c3a01cf084c6686cc2ce7aff Mon Sep 17 00:00:00 2001 From: Francesco Rodriguez Date: Mon, 21 May 2012 23:30:13 -0500 Subject: add CollectionProxy#delete_all documentation --- .../active_record/associations/collection_proxy.rb | 65 ++++++++++++++++++++++ 1 file changed, 65 insertions(+) diff --git a/activerecord/lib/active_record/associations/collection_proxy.rb b/activerecord/lib/active_record/associations/collection_proxy.rb index b419b9a749..650d68a64a 100644 --- a/activerecord/lib/active_record/associations/collection_proxy.rb +++ b/activerecord/lib/active_record/associations/collection_proxy.rb @@ -218,6 +218,71 @@ module ActiveRecord # # person.pets.replace(["doo", "ggie", "gaga"]) # # => ActiveRecord::AssociationTypeMismatch: Pet expected, got String + + + ## + # :method: delete_all + # Deletes all the records from the collection. For +has_many+ it will do the + # deletion according to the strategy specified by the :dependent + # option. Returns an array with the deleted records. + # + # If no :dependent option is given, then it will follow the + # default strategy. The default strategy is :nullify. This + # sets the foreign keys to NULL. + # + # class Person < ActiveRecord::Base + # has_many :pets # dependent: :nullify option by default + # end + # + # person.pets.size # => 3 + # person.pets + # # => [ + # # #, + # # #, + # # # + # # ] + # + # person.pets.delete_all + # # => [ + # # #, + # # #, + # # # + # # ] + # + # person.pets.size # => 0 + # person.pets # => [] + # + # Pet.find(1, 2, 3) + # # => [ + # # #, + # # #, + # # # + # # ] + # + # If it is set to :destroy all the objects from the collection + # are destroyed by calling their +destroy+ method. + # + # class Person < ActiveRecord::Base + # has_many :pets, dependent: :destroy + # end + # + # person.pets.size # => 3 + # person.pets + # # => [ + # # #, + # # #, + # # # + # # ] + # + # person.pets.delete_all + # # => [ + # # #, + # # #, + # # # + # # ] + # + # Pet.find(1, 2, 3) + # # => ActiveRecord::RecordNotFound ## # :method: destroy_all -- cgit v1.2.3 From 1bcd5e42ed6c2efed4d1a53e74b4f8d6631b119d Mon Sep 17 00:00:00 2001 From: Francesco Rodriguez Date: Mon, 21 May 2012 23:49:41 -0500 Subject: update CollectionProxy#delete_all documentation --- .../active_record/associations/collection_proxy.rb | 31 ++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/activerecord/lib/active_record/associations/collection_proxy.rb b/activerecord/lib/active_record/associations/collection_proxy.rb index 650d68a64a..f0c4688ee3 100644 --- a/activerecord/lib/active_record/associations/collection_proxy.rb +++ b/activerecord/lib/active_record/associations/collection_proxy.rb @@ -228,7 +228,8 @@ module ActiveRecord # # If no :dependent option is given, then it will follow the # default strategy. The default strategy is :nullify. This - # sets the foreign keys to NULL. + # sets the foreign keys to NULL. For, +has_many+ :through, + # the default strategy is +delete_all+. # # class Person < ActiveRecord::Base # has_many :pets # dependent: :nullify option by default @@ -260,7 +261,8 @@ module ActiveRecord # # ] # # If it is set to :destroy all the objects from the collection - # are destroyed by calling their +destroy+ method. + # are removed by calling their +destroy+ method. See +destroy+ for more + # information. # # class Person < ActiveRecord::Base # has_many :pets, dependent: :destroy @@ -283,6 +285,31 @@ module ActiveRecord # # Pet.find(1, 2, 3) # # => ActiveRecord::RecordNotFound + # + # If it is set to :delete_all, all the objects are deleted + # *without* calling their +destroy+ method. + # + # class Person < ActiveRecord::Base + # has_many :pets, dependent: :delete_all + # end + # + # person.pets.size # => 3 + # person.pets + # # => [ + # # #, + # # #, + # # # + # # ] + # + # person.pets.delete_all + # # => [ + # # #, + # # #, + # # # + # # ] + # + # Pet.find(1, 2, 3) + # # => ActiveRecord::RecordNotFound ## # :method: destroy_all -- cgit v1.2.3 From 8281194fee1a049826c50f9e0a095ea1abb91277 Mon Sep 17 00:00:00 2001 From: Francesco Rodriguez Date: Mon, 21 May 2012 23:51:31 -0500 Subject: update CollectionProxy#clear documentation --- activerecord/lib/active_record/associations/collection_proxy.rb | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/activerecord/lib/active_record/associations/collection_proxy.rb b/activerecord/lib/active_record/associations/collection_proxy.rb index f0c4688ee3..468bf5c2f8 100644 --- a/activerecord/lib/active_record/associations/collection_proxy.rb +++ b/activerecord/lib/active_record/associations/collection_proxy.rb @@ -577,9 +577,8 @@ module ActiveRecord end alias_method :push, :<< - # Removes every object from the collection. This does not destroy - # the objects, it sets their foreign keys to +NULL+. Returns +self+ - # so methods can be chained. + # Equivalent to +delete_all+. The difference is that returns +self+, instead + # of an array with the deleted objects, so methods can be chained. # # class Person < ActiveRecord::Base # has_many :pets -- cgit v1.2.3 From 4220290d09e682d8454048312b89efaf84f028be Mon Sep 17 00:00:00 2001 From: Gaurish Sharma Date: Tue, 22 May 2012 11:19:32 +0530 Subject: Fix broken link --- guides/source/debugging_rails_applications.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guides/source/debugging_rails_applications.textile b/guides/source/debugging_rails_applications.textile index 45fa4ada78..0802a2db26 100644 --- a/guides/source/debugging_rails_applications.textile +++ b/guides/source/debugging_rails_applications.textile @@ -698,7 +698,7 @@ There are some Rails plugins to help you to find errors and debug your applicati h3. References -* "ruby-debug Homepage":http://www.datanoise.com/ruby-debug +* "ruby-debug Homepage":http://bashdb.sourceforge.net/ruby-debug/home-page.html * "debugger Homepage":http://github.com/cldwalker/debugger * "Article: Debugging a Rails application with ruby-debug":http://www.sitepoint.com/article/debug-rails-app-ruby-debug/ * "ruby-debug Basics screencast":http://brian.maybeyoureinsane.net/blog/2007/05/07/ruby-debug-basics-screencast/ -- cgit v1.2.3 From 09be6921590a7e4ded515deb8ce77566fa41fed5 Mon Sep 17 00:00:00 2001 From: Alexey Vakhov Date: Tue, 22 May 2012 11:45:59 +0400 Subject: Remove obsolete comment from generator gem method This comment about :env option for gem method was actual for rails 2.3 without bundler. Now bundler uses grups for this goal. --- railties/lib/rails/generators/actions.rb | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/railties/lib/rails/generators/actions.rb b/railties/lib/rails/generators/actions.rb index 6cd2ea2bbd..703501e6f0 100644 --- a/railties/lib/rails/generators/actions.rb +++ b/railties/lib/rails/generators/actions.rb @@ -5,8 +5,7 @@ module Rails module Generators module Actions - # Adds an entry into Gemfile for the supplied gem. If env - # is specified, add the gem to the given environment. + # Adds an entry into Gemfile for the supplied gem. # # gem "rspec", :group => :test # gem "technoweenie-restful-authentication", :lib => "restful-authentication", :source => "http://gems.github.com/" -- cgit v1.2.3 From feaa7b35a0214240eb34780ab51b843571e74904 Mon Sep 17 00:00:00 2001 From: Gaurish Sharma Date: Tue, 22 May 2012 19:29:25 +0530 Subject: Remove Obsolute root specifiying short syntax This syntax does not seem to work. Throws the error "can't convert String into Hash (TypeError)" Tested on: * Ruby 1.9.3 * Rails 3.2.3 --- guides/source/routing.textile | 1 - 1 file changed, 1 deletion(-) diff --git a/guides/source/routing.textile b/guides/source/routing.textile index 4a50edbb15..6081651364 100644 --- a/guides/source/routing.textile +++ b/guides/source/routing.textile @@ -629,7 +629,6 @@ You can specify what Rails should route +"/"+ to with the +root+ method: root :to => 'pages#main' -root 'pages#main' # shortcut for the above You should put the +root+ route at the top of the file, because it is the most popular route and should be matched first. You also need to delete the +public/index.html+ file for the root route to take effect. -- cgit v1.2.3 From d1cab8e5e0aba87e307a387f1b8267e5c41419c6 Mon Sep 17 00:00:00 2001 From: Francesco Rodriguez Date: Tue, 22 May 2012 09:55:13 -0500 Subject: remove repeated documentation in CollectionProxy#clear --- .../active_record/associations/collection_proxy.rb | 26 ++-------------------- 1 file changed, 2 insertions(+), 24 deletions(-) diff --git a/activerecord/lib/active_record/associations/collection_proxy.rb b/activerecord/lib/active_record/associations/collection_proxy.rb index 468bf5c2f8..9ee69157b3 100644 --- a/activerecord/lib/active_record/associations/collection_proxy.rb +++ b/activerecord/lib/active_record/associations/collection_proxy.rb @@ -578,30 +578,8 @@ module ActiveRecord alias_method :push, :<< # Equivalent to +delete_all+. The difference is that returns +self+, instead - # of an array with the deleted objects, so methods can be chained. - # - # class Person < ActiveRecord::Base - # has_many :pets - # end - # - # person.pets # => [#] - # person.pets.clear # => [] - # person.pets.size # => 0 - # - # Pet.find(1) # => # - # - # If they are associated with dependent: :destroy option, it deletes - # them directly from the database. - # - # class Person < ActiveRecord::Base - # has_many :pets, dependent: :destroy - # end - # - # person.pets # => [#] - # person.pets.clear # => [] - # person.pets.size # => 0 - # - # Pet.find(2) # => ActiveRecord::RecordNotFound: Couldn't find Pet with id=2 + # of an array with the deleted objects, so methods can be chained. See + # +delete_all+ for more information. def clear delete_all self -- cgit v1.2.3 From acdf8ac58dbf71ac274dc93fd9b4c6da539a36b3 Mon Sep 17 00:00:00 2001 From: Oscar Del Ben Date: Tue, 22 May 2012 08:32:12 -0700 Subject: The initialization guide will cover Rails 4 --- guides/source/initialization.textile | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/guides/source/initialization.textile b/guides/source/initialization.textile index 155a439e64..361045282a 100644 --- a/guides/source/initialization.textile +++ b/guides/source/initialization.textile @@ -1,13 +1,15 @@ h2. The Rails Initialization Process -This guide explains the internals of the initialization process in Rails as of Rails 3.1. It is an extremely in-depth guide and recommended for advanced Rails developers. +This guide explains the internals of the initialization process in Rails +as of Rails 4. It is an extremely in-depth guide and recommended for advanced Rails developers. * Using +rails server+ * Using Passenger endprologue. -This guide goes through every single file, class and method call that is required to boot up the Ruby on Rails stack for a default Rails 3.1 application, explaining each part in detail along the way. For this guide, we will be focusing on how the two most common methods (+rails server+ and Passenger) boot a Rails application. +This guide goes through every single file, class and method call that is +required to boot up the Ruby on Rails stack for a default Rails 4 application, explaining each part in detail along the way. For this guide, we will be focusing on how the two most common methods (+rails server+ and Passenger) boot a Rails application. NOTE: Paths in this guide are relative to Rails or a Rails application unless otherwise specified. -- cgit v1.2.3 From d4d87941cbf4d8204c8d3ac6f4a87c29e42445b0 Mon Sep 17 00:00:00 2001 From: Oscar Del Ben Date: Tue, 22 May 2012 08:35:49 -0700 Subject: [Guides] change rails bin section --- guides/source/initialization.textile | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/guides/source/initialization.textile b/guides/source/initialization.textile index 361045282a..5ffa62fd67 100644 --- a/guides/source/initialization.textile +++ b/guides/source/initialization.textile @@ -24,16 +24,15 @@ The actual +rails+ command is kept in _bin/rails_: #!/usr/bin/env ruby -begin - require "rails/cli" -rescue LoadError - railties_path = File.expand_path('../../railties/lib', __FILE__) +if File.exists?(File.join(File.expand_path('../../..', __FILE__), '.git')) + railties_path = File.expand_path('../../lib', __FILE__) $:.unshift(railties_path) - require "rails/cli" end +require "rails/cli" -This file will attempt to load +rails/cli+. If it cannot find it then +railties/lib+ is added to the load path (+$:+) before retrying. +This file will first attempt to push the +railties/lib+ directory if +present, and then require +rails/cli+. h4. +railties/lib/rails/cli.rb+ -- cgit v1.2.3 From 987a74da23b7ef28a9564f20a3bf87b26530fa2f Mon Sep 17 00:00:00 2001 From: Oscar Del Ben Date: Tue, 22 May 2012 08:43:14 -0700 Subject: [Guides] Review bin/rails section --- guides/source/initialization.textile | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/guides/source/initialization.textile b/guides/source/initialization.textile index 5ffa62fd67..a1420d3b6a 100644 --- a/guides/source/initialization.textile +++ b/guides/source/initialization.textile @@ -47,7 +47,7 @@ require 'rails/script_rails_loader' Rails::ScriptRailsLoader.exec_script_rails! require 'rails/ruby_version_check' -Signal.trap("INT") { puts; exit } +Signal.trap("INT") { puts; exit(1) } if ARGV.first == 'plugin' ARGV.shift @@ -57,7 +57,7 @@ else end -The +rbconfig+ file from the Ruby standard library provides us with the +RbConfig+ class which contains detailed information about the Ruby environment, including how Ruby was compiled. We can see this in use in +railties/lib/rails/script_rails_loader+. +The +rbconfig+ file from the Ruby standard library provides us with the +RbConfig+ class which contains detailed information about the Ruby environment, including how Ruby was compiled. We can see thisin use in +railties/lib/rails/script_rails_loader+. require 'pathname' @@ -121,6 +121,9 @@ exec RUBY, SCRIPT_RAILS, *ARGV if in_rails_application? This is effectively the same as running +ruby script/rails [arguments]+, where +[arguments]+ at this point in time is simply "server". +TIP: If you execute +script/rails+ directly from your Rails app you will +avoid executing the code that we just described. + h4. +script/rails+ This file is as follows: -- cgit v1.2.3 From ba55dd59ece04aa11bdb305dddfe4e975de9177a Mon Sep 17 00:00:00 2001 From: Oscar Del Ben Date: Tue, 22 May 2012 08:48:46 -0700 Subject: [Guides] Change bundler section --- guides/source/initialization.textile | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/guides/source/initialization.textile b/guides/source/initialization.textile index a1420d3b6a..fdbee7b332 100644 --- a/guides/source/initialization.textile +++ b/guides/source/initialization.textile @@ -138,23 +138,23 @@ The +APP_PATH+ constant will be used later in +rails/commands+. The +config/boot h4. +config/boot.rb+ -+config/boot.rb+ contains this: ++config/boot.rb+ contains: # Set up gems listed in the Gemfile. -gemfile = File.expand_path('../../Gemfile', __FILE__) -begin - ENV['BUNDLE_GEMFILE'] = gemfile - require 'bundler' - Bundler.setup -rescue Bundler::GemNotFound => e - STDERR.puts e.message - STDERR.puts "Try running `bundle install`." - exit! -end if File.exist?(gemfile) +ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) + +require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE']) -In a standard Rails application, there's a +Gemfile+ which declares all dependencies of the application. +config/boot.rb+ sets +ENV["BUNDLE_GEMFILE"]+ to the location of this file, then requires Bundler and calls +Bundler.setup+ which adds the dependencies of the application (including all the Rails parts) to the load path, making them available for the application to load. The gems that a Rails 3.1 application depends on are as follows: +In a standard Rails application, there's a +Gemfile+ which declares all +dependencies of the application. +config/boot.rb+ sets ++ENV['BUNDLE_GEMFILE']+ to the location of this file. If the Gemfile +exists, +bundler/setup+ is then required. + +The gems that a Rails 4 application depends on are as follows: + +TODO: change these when the Rails 4 release is near. * abstract (1.0.0) * actionmailer (3.1.0.beta) -- cgit v1.2.3 From 63f094bf2984127132589f5c93e6dabcad898b12 Mon Sep 17 00:00:00 2001 From: Oscar Del Ben Date: Tue, 22 May 2012 08:55:59 -0700 Subject: [Guides] Update rails commands section --- guides/source/initialization.textile | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/guides/source/initialization.textile b/guides/source/initialization.textile index fdbee7b332..dc089bfb90 100644 --- a/guides/source/initialization.textile +++ b/guides/source/initialization.textile @@ -187,6 +187,8 @@ h4. +rails/commands.rb+ Once +config/boot.rb+ has finished, the next file that is required is +rails/commands+ which will execute a command based on the arguments passed in. In this case, the +ARGV+ array simply contains +server+ which is extracted into the +command+ variable using these lines: +ARGV << '--help' if ARGV.empty? + aliases = { "g" => "generate", "c" => "console", @@ -199,6 +201,9 @@ command = ARGV.shift command = aliases[command] || command +TIP: As you can see, an empty ARGV list will make Rails show the help +snippet. + If we used s rather than +server+, Rails will use the +aliases+ defined in the file and match them to their respective commands. With the +server+ command, Rails will run this code: -- cgit v1.2.3 From 2c62dd64dbaf1b3c758e7259fa8fefbafbbdcf81 Mon Sep 17 00:00:00 2001 From: Francesco Rodriguez Date: Tue, 22 May 2012 11:02:43 -0500 Subject: add CollectionProxy#build documentation --- .../active_record/associations/collection_proxy.rb | 31 ++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/activerecord/lib/active_record/associations/collection_proxy.rb b/activerecord/lib/active_record/associations/collection_proxy.rb index 9ee69157b3..6c8fcec0c4 100644 --- a/activerecord/lib/active_record/associations/collection_proxy.rb +++ b/activerecord/lib/active_record/associations/collection_proxy.rb @@ -167,6 +167,37 @@ module ActiveRecord # another_person_without.pets.last # => nil # another_person_without.pets.last(3) # => [] + ## + # :method: build + # + # :call-seq: + # build(attributes = {}, options = {}, &block) + # + # Returns a new object of the collection type that has been instantiated + # with +attributes+ and linked to this object, but have not yet been saved. + # You can pass an array of attributes hashes, this will return an array + # with the new objects. + # + # class Person + # has_many :pets + # end + # + # person.pets.build + # # => # + # + # person.pets.build(name: 'Fancy-Fancy') + # # => # + # + # person.pets.build([{name: 'Spook'}, {name: 'Choo-Choo'}, {name: 'Brain'}]) + # # => [ + # # #, + # # #, + # # # + # # ] + # + # person.pets.size # => 5 # size of the collection + # person.pets.count # => 0 # count from database + ## # :method: concat # Add one or more records to the collection by setting their foreign keys -- cgit v1.2.3 From 21f4c2eb593f62658bbf5691c60ec3da3b0ab76d Mon Sep 17 00:00:00 2001 From: Francesco Rodriguez Date: Tue, 22 May 2012 11:13:31 -0500 Subject: adding :call-seq: to CollectionProxy methods --- .../active_record/associations/collection_proxy.rb | 39 ++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/activerecord/lib/active_record/associations/collection_proxy.rb b/activerecord/lib/active_record/associations/collection_proxy.rb index 6c8fcec0c4..6d1ba188c3 100644 --- a/activerecord/lib/active_record/associations/collection_proxy.rb +++ b/activerecord/lib/active_record/associations/collection_proxy.rb @@ -39,6 +39,10 @@ module ActiveRecord ## # :method: select # + # :call-seq: + # select(select = nil) + # select(&block) + # # Works in two ways. # # *First:* Specify a subset of fields to be selected from the result set. @@ -91,6 +95,10 @@ module ActiveRecord ## # :method: find + # + # :call-seq: + # find(*args, &block) + # # Finds an object in the collection responding to the +id+. Uses the same # rules as +ActiveRecord::Base.find+. Returns +ActiveRecord::RecordNotFound++ # error if the object can not be found. @@ -111,6 +119,7 @@ module ActiveRecord ## # :method: first + # # Returns the first record, or the first +n+ records, from the collection. # If the collection is empty, the first form returns +nil+, and the second # form returns an empty array. @@ -140,6 +149,7 @@ module ActiveRecord ## # :method: last + # # Returns the last record, or the last +n+ records, from the collection. # If the collection is empty, the first form returns +nil+, and the second # form returns an empty array. @@ -200,6 +210,10 @@ module ActiveRecord ## # :method: concat + # + # :call-seq: + # concat(*records) + # # Add one or more records to the collection by setting their foreign keys # to the association's primary key. Since << flattens its argument list and # inserts each record, +push+ and +concat+ behave identically. Returns +self+ @@ -227,6 +241,10 @@ module ActiveRecord ## # :method: replace + # + # :call-seq: + # replace(other_array) + # # Replace this collection with +other_array+. This will perform a diff # and delete/add only records that have changed. # @@ -253,6 +271,7 @@ module ActiveRecord ## # :method: delete_all + # # Deletes all the records from the collection. For +has_many+ it will do the # deletion according to the strategy specified by the :dependent # option. Returns an array with the deleted records. @@ -344,6 +363,7 @@ module ActiveRecord ## # :method: destroy_all + # # Deletes the records of the collection directly from the database. # This will _always_ remove the records ignoring the +:dependent+ # option. @@ -369,6 +389,10 @@ module ActiveRecord ## # :method: destroy + # + # :call-seq: + # destroy(*records) + # # Destroy the +records+ supplied and remove them from the collection. # This method will _always_ remove record from the database ignoring # the +:dependent+ option. Returns an array with the removed records. @@ -440,6 +464,7 @@ module ActiveRecord ## # :method: empty? + # # Returns +true+ if the collection is empty. # # class Person < ActiveRecord::Base @@ -456,6 +481,11 @@ module ActiveRecord ## # :method: any? + # + # :call-seq: + # any? + # any?{|item| block} + # # Returns +true+ if the collection is not empty. # # class Person < ActiveRecord::Base @@ -488,6 +518,11 @@ module ActiveRecord ## # :method: many? + # + # :call-seq: + # many? + # many?{|item| block} + # # Returns true if the collection has more than one record. # Equivalent to collection.size > 1. # @@ -525,6 +560,10 @@ module ActiveRecord ## # :method: include? + # + # :call-seq: + # include?(record) + # # Returns +true+ if the given object is present in the collection. # # class Person < ActiveRecord::Base -- cgit v1.2.3 From e0859e569c007cd108797883eec402c876b9e8a0 Mon Sep 17 00:00:00 2001 From: Francesco Rodriguez Date: Tue, 22 May 2012 11:27:04 -0500 Subject: add more examples to CollectionProxy#find --- activerecord/lib/active_record/associations/collection_proxy.rb | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/activerecord/lib/active_record/associations/collection_proxy.rb b/activerecord/lib/active_record/associations/collection_proxy.rb index 6d1ba188c3..33779a9ad7 100644 --- a/activerecord/lib/active_record/associations/collection_proxy.rb +++ b/activerecord/lib/active_record/associations/collection_proxy.rb @@ -116,6 +116,15 @@ module ActiveRecord # # person.pets.find(1) # => # # person.pets.find(4) # => ActiveRecord::RecordNotFound: Couldn't find Pet with id=4 + # + # person.pets.find(2) { |pet| pet.name.downcase! } + # # => # + # + # person.pets.find(2, 3) + # # => [ + # # #, + # # # + # # ] ## # :method: first -- cgit v1.2.3 From 9c38cfc44afc2c8a9ab79801ff23c53f833d1085 Mon Sep 17 00:00:00 2001 From: Francesco Rodriguez Date: Tue, 22 May 2012 11:39:13 -0500 Subject: add CollectionProxy#create documentation --- .../active_record/associations/collection_proxy.rb | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/activerecord/lib/active_record/associations/collection_proxy.rb b/activerecord/lib/active_record/associations/collection_proxy.rb index 33779a9ad7..6e73ac79e2 100644 --- a/activerecord/lib/active_record/associations/collection_proxy.rb +++ b/activerecord/lib/active_record/associations/collection_proxy.rb @@ -217,6 +217,39 @@ module ActiveRecord # person.pets.size # => 5 # size of the collection # person.pets.count # => 0 # count from database + ## + # :method: create + # + # :call-seq: + # create(attributes = {}, options = {}, &block) + # + # Returns a new object of the collection type that has been instantiated with + # attributes, linked to this object and that has already been saved (if it + # passed the validations). + # + # class Person + # has_many :pets + # end + # + # person.pets.create(name: 'Fancy-Fancy') + # # => # + # + # person.pets.create([{name: 'Spook'}, {name: 'Choo-Choo'}]) + # # => [ + # # #, + # # # + # # ] + # + # person.pets.size # => 3 + # person.pets.count # => 3 + # + # person.pets.find(1, 2, 3) + # # => [ + # # #, + # # #, + # # # + # # ] + ## # :method: concat # -- cgit v1.2.3 From 7e5beca38fe64344eb8b97c9fba93096ff533543 Mon Sep 17 00:00:00 2001 From: Francesco Rodriguez Date: Tue, 22 May 2012 11:52:14 -0500 Subject: add CollectionProxy#create! documentation --- .../active_record/associations/collection_proxy.rb | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/activerecord/lib/active_record/associations/collection_proxy.rb b/activerecord/lib/active_record/associations/collection_proxy.rb index 6e73ac79e2..6d001e8d10 100644 --- a/activerecord/lib/active_record/associations/collection_proxy.rb +++ b/activerecord/lib/active_record/associations/collection_proxy.rb @@ -249,6 +249,28 @@ module ActiveRecord # # #, # # # # # ] + + ## + # :method: create! + # + # :call-seq: + # create!(attributes = {}, options = {}, &block) + # + # Like +create+, except that if the record is invalid will + # raise an exception. + # + # class Person + # has_many :pets + # end + # + # class Pet + # attr_accessible :name + # validates :name, presence: true + # end + # + # person.pets.create!(name: nil) + # # => ActiveRecord::RecordInvalid: Validation failed: Name can't be blank + ## # :method: concat -- cgit v1.2.3 From 3e847afbdd88d53bbf85eb2436ead2dab88f6e5b Mon Sep 17 00:00:00 2001 From: Francesco Rodriguez Date: Tue, 22 May 2012 11:55:30 -0500 Subject: add :call-seq: to +first+ and +last+ CollectionProxy methods --- activerecord/lib/active_record/associations/collection_proxy.rb | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/activerecord/lib/active_record/associations/collection_proxy.rb b/activerecord/lib/active_record/associations/collection_proxy.rb index 6d001e8d10..776d65294e 100644 --- a/activerecord/lib/active_record/associations/collection_proxy.rb +++ b/activerecord/lib/active_record/associations/collection_proxy.rb @@ -129,6 +129,9 @@ module ActiveRecord ## # :method: first # + # :call-seq: + # first(limit = nil) + # # Returns the first record, or the first +n+ records, from the collection. # If the collection is empty, the first form returns +nil+, and the second # form returns an empty array. @@ -159,6 +162,9 @@ module ActiveRecord ## # :method: last # + # :call-seq: + # last(limit = nil) + # # Returns the last record, or the last +n+ records, from the collection. # If the collection is empty, the first form returns +nil+, and the second # form returns an empty array. -- cgit v1.2.3 From f539d98cc8838b0f7c3c31465cdc070ab9c1e9f3 Mon Sep 17 00:00:00 2001 From: Francesco Rodriguez Date: Tue, 22 May 2012 12:17:00 -0500 Subject: add CollectionProxy#size documentation --- .../active_record/associations/collection_proxy.rb | 27 ++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/activerecord/lib/active_record/associations/collection_proxy.rb b/activerecord/lib/active_record/associations/collection_proxy.rb index 776d65294e..bc310cd13e 100644 --- a/activerecord/lib/active_record/associations/collection_proxy.rb +++ b/activerecord/lib/active_record/associations/collection_proxy.rb @@ -277,7 +277,6 @@ module ActiveRecord # person.pets.create!(name: nil) # # => ActiveRecord::RecordInvalid: Validation failed: Name can't be blank - ## # :method: concat # @@ -337,7 +336,6 @@ module ActiveRecord # # person.pets.replace(["doo", "ggie", "gaga"]) # # => ActiveRecord::AssociationTypeMismatch: Pet expected, got String - ## # :method: delete_all @@ -531,6 +529,31 @@ module ActiveRecord # person.pets # => [] # # Pet.find(4, 5, 6) # => ActiveRecord::RecordNotFound: Couldn't find all Pets with IDs (4, 5, 6) + + ## + # :method: size + # + # Returns the size of the collection. If the collection hasn't been loaded, + # it executes a SELECT COUNT(*) query. + # + # class Person < ActiveRecord::Base + # has_many :pets + # end + # + # # This will execute: + # # SELECT COUNT(*) FROM "pets" WHERE "pets"."person_id" = ? [["person_id", 1]] + # person.pets.size # => 3 + # + # person.pets + # # => [ + # # #, + # # #, + # # # + # # ] + # + # # Because the collection is already loaded, this will behave like + # collection.size and no SQL count query is executed. + # person.pets.size # => 3 ## # :method: empty? -- cgit v1.2.3 From eb2c0a4f712b015bf6886286efd6e5b2eeaf54aa Mon Sep 17 00:00:00 2001 From: Francesco Rodriguez Date: Tue, 22 May 2012 12:34:12 -0500 Subject: add CollectionProxy#length documentation --- .../active_record/associations/collection_proxy.rb | 42 +++++++++++++++++++--- 1 file changed, 37 insertions(+), 5 deletions(-) diff --git a/activerecord/lib/active_record/associations/collection_proxy.rb b/activerecord/lib/active_record/associations/collection_proxy.rb index bc310cd13e..6fd5c466f6 100644 --- a/activerecord/lib/active_record/associations/collection_proxy.rb +++ b/activerecord/lib/active_record/associations/collection_proxy.rb @@ -540,20 +540,52 @@ module ActiveRecord # has_many :pets # end # - # # This will execute: - # # SELECT COUNT(*) FROM "pets" WHERE "pets"."person_id" = ? [["person_id", 1]] # person.pets.size # => 3 + # # Executes: + # # + # # SELECT COUNT(*) + # # FROM "pets" + # # WHERE "pets"."person_id" = 1 # - # person.pets + # person.pets # This will execute a SELECT * FROM query # # => [ # # #, # # #, # # # # # ] # - # # Because the collection is already loaded, this will behave like - # collection.size and no SQL count query is executed. # person.pets.size # => 3 + # # Because the collection is already loaded, this will behave like + # # collection.size and no SQL count query is executed. + + ## + # :method: length + # + # Returns the size of the collection calling +size+ on the target. + # If the collection has been already loaded +length+ and +size+ are + # equivalent. If not and you are going to need the records anyway this + # method will take one less query because loads the collection. Otherwise + # +size+ is more efficient. + # + # class Person < ActiveRecord::Base + # has_many :pets + # end + # + # person.pets.length # => 3 + # # Executes: + # # + # # SELECT "pets".* + # #  FROM "pets" + # # WHERE "pets"."person_id" = 1 + # + # # Because the collection is loaded, you can + # # call the collection without execute a query: + # person.pets + # # => [ + # # #, + # # #, + # # # + # # ] ## # :method: empty? -- cgit v1.2.3 From f09c84ca26a73304943421d473faa3ea808d18ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rory=20O=E2=80=99Kane?= Date: Tue, 22 May 2012 15:50:19 -0300 Subject: clarified how file naming affects load order of initializers --- guides/source/configuring.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guides/source/configuring.textile b/guides/source/configuring.textile index f114075cae..af46538bf5 100644 --- a/guides/source/configuring.textile +++ b/guides/source/configuring.textile @@ -585,7 +585,7 @@ After loading the framework and any gems in your application, Rails turns to loa NOTE: You can use subfolders to organize your initializers if you like, because Rails will look into the whole file hierarchy from the initializers folder on down. -TIP: If you have any ordering dependency in your initializers, you can control the load order by naming. For example, +01_critical.rb+ will be loaded before +02_normal.rb+. +TIP: If you have any ordering dependency in your initializers, you can control the load order through naming. Initializer files are loaded in alphabetical order by their path. For example, +01_critical.rb+ will be loaded before +02_normal.rb+. h3. Initialization events -- cgit v1.2.3 From 2227064b2a26914f662878482fb00dc25546ecd8 Mon Sep 17 00:00:00 2001 From: David Morton Date: Tue, 22 May 2012 22:00:31 -0500 Subject: Fix incorrect example for fields_for - without the '=' it will not output anything. --- actionpack/lib/action_view/helpers/form_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/actionpack/lib/action_view/helpers/form_helper.rb b/actionpack/lib/action_view/helpers/form_helper.rb index 61e7a89585..12576ecd01 100644 --- a/actionpack/lib/action_view/helpers/form_helper.rb +++ b/actionpack/lib/action_view/helpers/form_helper.rb @@ -342,7 +342,7 @@ module ActionView # Example: # # <%= form_for(@post) do |f| %> - # <% f.fields_for(:comments, :include_id => false) do |cf| %> + # <%= f.fields_for(:comments, :include_id => false) do |cf| %> # ... # <% end %> # <% end %> -- cgit v1.2.3 From 05a4d8b8597b7cc70ea79b087ee491ffaaf8f504 Mon Sep 17 00:00:00 2001 From: Oscar Del Ben Date: Wed, 23 May 2012 08:45:48 -0700 Subject: [Guides] Rewrite server start section --- guides/source/initialization.textile | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/guides/source/initialization.textile b/guides/source/initialization.textile index dc089bfb90..78790a5e3c 100644 --- a/guides/source/initialization.textile +++ b/guides/source/initialization.textile @@ -370,8 +370,9 @@ This method is defined like this: def start + url = "#{options[:SSLEnable] ? 'https' : 'http'}://#{options[:Host]}:#{options[:Port]}" puts "=> Booting #{ActiveSupport::Inflector.demodulize(server)}" - puts "=> Rails #{Rails.version} application starting in #{Rails.env} on http://#{options[:Host]}:#{options[:Port]}" + puts "=> Rails #{Rails.version} application starting in #{Rails.env} on #{url}" puts "=> Call with -d to detach" unless options[:daemonize] trap(:INT) { exit } puts "=> Ctrl-C to shutdown server" unless options[:daemonize] @@ -381,6 +382,15 @@ def start FileUtils.mkdir_p(Rails.root.join('tmp', dir_to_make)) end + unless options[:daemonize] + wrapped_app # touch the app so the logger is set up + + console = ActiveSupport::Logger.new($stdout) + console.formatter = Rails.logger.formatter + + Rails.logger.extend(ActiveSupport::Logger.broadcast(console)) + end + super ensure # The '-h' option calls exit before @options is set. @@ -389,7 +399,15 @@ ensure end -This is where the first output of the Rails initialization happens. This method creates a trap for +INT+ signals, so if you +CTRL+C+ the server, it will exit the process. As we can see from the code here, it will create the +tmp/cache+, +tmp/pids+, +tmp/sessions+ and +tmp/sockets+ directories if they don't already exist prior to calling +super+. The +super+ method will call +Rack::Server.start+ which begins its definition like this: +This is where the first output of the Rails initialization happens. This +method creates a trap for +INT+ signals, so if you +CTRL-C+ the server, +it will exit the process. As we can see from the code here, it will +create the +tmp/cache+, +tmp/pids+, +tmp/sessions+ and +tmp/sockets+ +directories. It then calls +wrapped_app+ which is responsible for +creating the Rack app, before creating and assignig an +instance of +ActiveSupport::Logger+. + +The +super+ method will call +Rack::Server.start+ which begins its definition like this: def start -- cgit v1.2.3 From 13612ae5014a98cdbb86d703b50cbdf66adbcb57 Mon Sep 17 00:00:00 2001 From: Oscar Del Ben Date: Wed, 23 May 2012 08:53:08 -0700 Subject: [Guides] Rewrite server start section --- guides/source/initialization.textile | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/guides/source/initialization.textile b/guides/source/initialization.textile index 78790a5e3c..5ce8173e85 100644 --- a/guides/source/initialization.textile +++ b/guides/source/initialization.textile @@ -410,7 +410,7 @@ instance of +ActiveSupport::Logger+. The +super+ method will call +Rack::Server.start+ which begins its definition like this: -def start +def start &blk if options[:warn] $-w = true end @@ -430,22 +430,37 @@ def start pp wrapped_app pp app end -end - -In a Rails application, these options are not set at all and therefore aren't used at all. The first line of code that's executed in this method is a call to this method: + check_pid! if options[:pid] - -wrapped_app + # Touch the wrapped app, so that the config.ru is loaded before + # daemonization (i.e. before chdir, etc). + wrapped_app + + daemonize_app if options[:daemonize] + + write_pid if options[:pid] + + trap(:INT) do + if server.respond_to?(:shutdown) + server.shutdown + else + exit + end + end + + server.run wrapped_app, options, &blk +end -This method calls another method: +The interesting part for a Rails app is the last line, +server.run+. Here we encounter the +wrapped_app+ method again, which this time +we're going to explore more. @wrapped_app ||= build_app app -Then the +app+ method here is defined like so: +The +app+ method here is defined like so: def app -- cgit v1.2.3 From 07f73219c0aed3d633d9d9f809f45a1758a718ef Mon Sep 17 00:00:00 2001 From: Oscar Del Ben Date: Wed, 23 May 2012 09:01:21 -0700 Subject: [Guides] Fix sample code --- guides/source/initialization.textile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guides/source/initialization.textile b/guides/source/initialization.textile index 5ce8173e85..12b2eb7458 100644 --- a/guides/source/initialization.textile +++ b/guides/source/initialization.textile @@ -482,7 +482,7 @@ The +options[:config]+ value defaults to +config.ru+ which contains this: # This file is used by Rack-based servers to start the application. require ::File.expand_path('../config/environment', __FILE__) -run YourApp::Application +run <%= app_const %> -- cgit v1.2.3 From 2642c2961cda2074cc1495a4635898ca8ab33adf Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Wed, 23 May 2012 22:42:49 +0530 Subject: copy edit[ci skip] --- actionpack/lib/abstract_controller/base.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/actionpack/lib/abstract_controller/base.rb b/actionpack/lib/abstract_controller/base.rb index 32ec7ced0f..9c3960961b 100644 --- a/actionpack/lib/abstract_controller/base.rb +++ b/actionpack/lib/abstract_controller/base.rb @@ -141,7 +141,7 @@ module AbstractController # # Notice that action_methods.include?("foo") may return # false and available_action?("foo") returns true because - # available action consider actions that are also available + # this method considers actions that are also available # through other means, for example, implicit render ones. # # ==== Parameters -- cgit v1.2.3 From 1ad0b378cc081937c117577ab628f2160fcc448d Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Wed, 23 May 2012 22:43:08 +0530 Subject: Revert "Remove blank trailing comments" This reverts commit fa6d921e11363e9b8c4bc10f7aed0b9faffdc33a. 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] --- Rakefile | 1 + actionmailer/lib/action_mailer/delivery_methods.rb | 1 + .../lib/rails/generators/mailer/templates/mailer.rb | 1 + actionpack/lib/abstract_controller/helpers.rb | 1 + actionpack/lib/action_controller/base.rb | 1 + actionpack/lib/action_controller/metal.rb | 2 ++ actionpack/lib/action_controller/metal/helpers.rb | 1 + actionpack/lib/action_controller/metal/mime_responds.rb | 1 + actionpack/lib/action_controller/metal/responder.rb | 10 ++++++++++ actionpack/lib/action_controller/metal/streaming.rb | 1 + actionpack/lib/action_dispatch/http/mime_negotiation.rb | 2 ++ actionpack/lib/action_dispatch/middleware/reloader.rb | 1 + actionpack/lib/action_dispatch/routing.rb | 1 + actionpack/lib/action_dispatch/routing/mapper.rb | 1 + .../lib/action_dispatch/routing/polymorphic_routes.rb | 2 ++ actionpack/lib/action_dispatch/routing/redirection.rb | 1 + actionpack/lib/action_dispatch/routing/route_set.rb | 1 + actionpack/lib/action_dispatch/routing/url_for.rb | 1 + .../lib/action_dispatch/testing/assertions/routing.rb | 1 + .../helpers/asset_tag_helpers/stylesheet_tag_helpers.rb | 1 + actionpack/lib/action_view/helpers/capture_helper.rb | 1 + actionpack/lib/action_view/helpers/form_helper.rb | 11 +++++++++++ actionpack/lib/action_view/helpers/form_options_helper.rb | 3 +++ actionpack/lib/action_view/helpers/form_tag_helper.rb | 3 +++ actionpack/lib/action_view/helpers/number_helper.rb | 1 + actionpack/lib/action_view/helpers/output_safety_helper.rb | 1 + actionpack/lib/action_view/helpers/record_tag_helper.rb | 2 ++ actionpack/lib/action_view/helpers/rendering_helper.rb | 1 + actionpack/lib/action_view/helpers/sanitize_helper.rb | 12 ++++++++++++ actionpack/lib/action_view/helpers/tags/select.rb | 1 + actionpack/lib/action_view/helpers/url_helper.rb | 1 + actionpack/lib/action_view/template/resolver.rb | 1 + activemodel/lib/active_model/attribute_methods.rb | 1 + activemodel/lib/active_model/callbacks.rb | 1 + activemodel/lib/active_model/conversion.rb | 1 + activemodel/lib/active_model/errors.rb | 1 + activemodel/lib/active_model/lint.rb | 2 ++ activemodel/lib/active_model/mass_assignment_security.rb | 2 ++ activemodel/lib/active_model/observing.rb | 2 ++ activemodel/lib/active_model/serialization.rb | 1 + activemodel/lib/active_model/validations.rb | 2 ++ activemodel/lib/active_model/validations/validates.rb | 1 + activemodel/lib/active_model/validator.rb | 2 ++ activemodel/test/cases/validations/i18n_validation_test.rb | 1 + activerecord/lib/active_record/aggregations.rb | 2 ++ activerecord/lib/active_record/associations/association.rb | 1 + activerecord/lib/active_record/callbacks.rb | 1 + .../connection_adapters/abstract/schema_definitions.rb | 1 + .../connection_adapters/abstract/schema_statements.rb | 1 + .../lib/active_record/connection_adapters/mysql_adapter.rb | 1 + .../active_record/connection_adapters/postgresql_adapter.rb | 1 + .../active_record/connection_adapters/sqlite3_adapter.rb | 1 + activerecord/lib/active_record/locking/optimistic.rb | 1 + activerecord/lib/active_record/model.rb | 1 + activerecord/lib/active_record/observer.rb | 1 + activerecord/lib/active_record/persistence.rb | 1 + activerecord/lib/active_record/reflection.rb | 6 ++++++ activerecord/lib/active_record/relation/calculations.rb | 1 + activerecord/lib/active_record/relation/finder_methods.rb | 1 + activerecord/lib/active_record/relation/query_methods.rb | 3 +++ activerecord/lib/active_record/relation/spawn_methods.rb | 3 +++ activerecord/lib/active_record/validations/uniqueness.rb | 1 + activerecord/test/cases/attribute_methods_test.rb | 1 + activerecord/test/cases/validations/i18n_validation_test.rb | 1 + activerecord/test/models/subject.rb | 1 + activesupport/lib/active_support/benchmarkable.rb | 1 + activesupport/lib/active_support/callbacks.rb | 1 + activesupport/lib/active_support/concern.rb | 1 + activesupport/lib/active_support/configurable.rb | 2 ++ .../lib/active_support/core_ext/array/conversions.rb | 1 + activesupport/lib/active_support/core_ext/array/uniq_by.rb | 1 + activesupport/lib/active_support/core_ext/enumerable.rb | 2 ++ activesupport/lib/active_support/core_ext/hash/except.rb | 1 + .../lib/active_support/core_ext/hash/indifferent_access.rb | 2 ++ .../lib/active_support/core_ext/integer/inflections.rb | 2 ++ .../lib/active_support/core_ext/kernel/reporting.rb | 2 ++ .../lib/active_support/core_ext/module/anonymous.rb | 1 + .../lib/active_support/core_ext/module/delegation.rb | 1 + .../lib/active_support/core_ext/module/introspection.rb | 2 ++ activesupport/lib/active_support/core_ext/object/blank.rb | 7 +++++++ .../lib/active_support/core_ext/object/duplicable.rb | 5 +++++ .../lib/active_support/core_ext/object/with_options.rb | 1 + .../lib/active_support/core_ext/string/inflections.rb | 1 + .../lib/active_support/core_ext/string/output_safety.rb | 1 + activesupport/lib/active_support/file_update_checker.rb | 1 + .../lib/active_support/hash_with_indifferent_access.rb | 4 ++++ activesupport/lib/active_support/inflector/methods.rb | 1 + activesupport/lib/active_support/lazy_load_hooks.rb | 1 + activesupport/lib/active_support/log_subscriber.rb | 1 + .../lib/active_support/log_subscriber/test_helper.rb | 2 ++ activesupport/lib/active_support/message_encryptor.rb | 1 + activesupport/lib/active_support/notifications.rb | 1 + activesupport/lib/active_support/ordered_options.rb | 1 + activesupport/lib/active_support/string_inquirer.rb | 1 + activesupport/lib/active_support/time_with_zone.rb | 2 ++ railties/lib/rails/application.rb | 1 + railties/lib/rails/configuration.rb | 1 + railties/lib/rails/engine/configuration.rb | 1 + railties/lib/rails/generators/active_model.rb | 1 + railties/lib/rails/generators/base.rb | 1 + railties/lib/rails/generators/named_base.rb | 1 + railties/lib/rails/generators/resource_helpers.rb | 2 ++ railties/lib/rails/generators/test_case.rb | 13 +++++++++++++ railties/lib/rails/railtie.rb | 1 + railties/test/generators/shared_generator_tests.rb | 1 + 105 files changed, 192 insertions(+) diff --git a/Rakefile b/Rakefile index be42c81f1f..21eb60bbe1 100644 --- a/Rakefile +++ b/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| diff --git a/actionmailer/lib/action_mailer/delivery_methods.rb b/actionmailer/lib/action_mailer/delivery_methods.rb index d2ec48b1ab..3b38dbccc7 100644 --- a/actionmailer/lib/action_mailer/delivery_methods.rb +++ b/actionmailer/lib/action_mailer/delivery_methods.rb @@ -50,6 +50,7 @@ module ActionMailer # 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) diff --git a/actionmailer/lib/rails/generators/mailer/templates/mailer.rb b/actionmailer/lib/rails/generators/mailer/templates/mailer.rb index 835fc9b148..edcfb4233d 100644 --- a/actionmailer/lib/rails/generators/mailer/templates/mailer.rb +++ b/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" diff --git a/actionpack/lib/abstract_controller/helpers.rb b/actionpack/lib/abstract_controller/helpers.rb index 529f920e6c..4e0672d590 100644 --- a/actionpack/lib/abstract_controller/helpers.rb +++ b/actionpack/lib/abstract_controller/helpers.rb @@ -90,6 +90,7 @@ module AbstractController # +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) diff --git a/actionpack/lib/action_controller/base.rb b/actionpack/lib/action_controller/base.rb index 90058245f5..71425cd542 100644 --- a/actionpack/lib/action_controller/base.rb +++ b/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! diff --git a/actionpack/lib/action_controller/metal.rb b/actionpack/lib/action_controller/metal.rb index 720c0f2258..92433ab462 100644 --- a/actionpack/lib/action_controller/metal.rb +++ b/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 @@ module ActionController # # You can refer to the modules included in ActionController::Base to see # other features you can bring into your metal controller. + # class Metal < AbstractController::Base abstract! diff --git a/actionpack/lib/action_controller/metal/helpers.rb b/actionpack/lib/action_controller/metal/helpers.rb index 598bc6c5cb..86d061e3b7 100644 --- a/actionpack/lib/action_controller/metal/helpers.rb +++ b/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 diff --git a/actionpack/lib/action_controller/metal/mime_responds.rb b/actionpack/lib/action_controller/metal/mime_responds.rb index d9fc777250..0b800c3c62 100644 --- a/actionpack/lib/action_controller/metal/mime_responds.rb +++ b/actionpack/lib/action_controller/metal/mime_responds.rb @@ -52,6 +52,7 @@ module ActionController #:nodoc: end # Clear all mime types in respond_to. + # def clear_respond_to self.mimes_for_respond_to = Hash.new.freeze end diff --git a/actionpack/lib/action_controller/metal/responder.rb b/actionpack/lib/action_controller/metal/responder.rb index 5aa3b2ca15..83407846dc 100644 --- a/actionpack/lib/action_controller/metal/responder.rb +++ b/actionpack/lib/action_controller/metal/responder.rb @@ -142,11 +142,13 @@ module ActionController #:nodoc: # 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 @@ module ActionController #:nodoc: # 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 @@ module ActionController #:nodoc: # 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 @@ module ActionController #:nodoc: 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 @@ module ActionController #:nodoc: # 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 @@ module ActionController #:nodoc: # 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 @@ module ActionController #:nodoc: end # Check whether the resource has errors. + # def has_errors? resource.respond_to?(:errors) && !resource.errors.empty? end # By default, render the :edit action for HTML requests with errors, unless # the verb was POST. + # def default_action @action ||= DEFAULT_ACTIONS_FOR_VERBS[request.request_method_symbol] end diff --git a/actionpack/lib/action_controller/metal/streaming.rb b/actionpack/lib/action_controller/metal/streaming.rb index 0c3caa9514..eeb37db2e7 100644 --- a/actionpack/lib/action_controller/metal/streaming.rb +++ b/actionpack/lib/action_controller/metal/streaming.rb @@ -194,6 +194,7 @@ module ActionController #:nodoc: # ==== Passenger # # To be described. + # module Streaming extend ActiveSupport::Concern diff --git a/actionpack/lib/action_dispatch/http/mime_negotiation.rb b/actionpack/lib/action_dispatch/http/mime_negotiation.rb index ca40ab9502..e31f3b823d 100644 --- a/actionpack/lib/action_dispatch/http/mime_negotiation.rb +++ b/actionpack/lib/action_dispatch/http/mime_negotiation.rb @@ -46,6 +46,7 @@ module ActionDispatch # 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 @@ module ActionDispatch # 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 diff --git a/actionpack/lib/action_dispatch/middleware/reloader.rb b/actionpack/lib/action_dispatch/middleware/reloader.rb index 23415dae54..2f6968eb2e 100644 --- a/actionpack/lib/action_dispatch/middleware/reloader.rb +++ b/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 ActionDispatch::Reloader.prepare! # or ActionDispatch::Reloader.cleanup! are called manually. + # class Reloader include ActiveSupport::Callbacks diff --git a/actionpack/lib/action_dispatch/routing.rb b/actionpack/lib/action_dispatch/routing.rb index a2a6fb39dc..38a0270151 100644 --- a/actionpack/lib/action_dispatch/routing.rb +++ b/actionpack/lib/action_dispatch/routing.rb @@ -277,6 +277,7 @@ module ActionDispatch # rake routes # # Target specific controllers by prefixing the command with CONTROLLER=x. + # module Routing autoload :Mapper, 'action_dispatch/routing/mapper' autoload :RouteSet, 'action_dispatch/routing/route_set' diff --git a/actionpack/lib/action_dispatch/routing/mapper.rb b/actionpack/lib/action_dispatch/routing/mapper.rb index 79eee21619..67a208263b 100644 --- a/actionpack/lib/action_dispatch/routing/mapper.rb +++ b/actionpack/lib/action_dispatch/routing/mapper.rb @@ -897,6 +897,7 @@ module ActionDispatch # 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. diff --git a/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb b/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb index 817cdb2d4e..8fde667108 100644 --- a/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb +++ b/actionpack/lib/action_dispatch/routing/polymorphic_routes.rb @@ -51,6 +51,7 @@ module ActionDispatch # # 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 ActionDispatch # # # 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 diff --git a/actionpack/lib/action_dispatch/routing/redirection.rb b/actionpack/lib/action_dispatch/routing/redirection.rb index d8beba4397..b3823bb496 100644 --- a/actionpack/lib/action_dispatch/routing/redirection.rb +++ b/actionpack/lib/action_dispatch/routing/redirection.rb @@ -121,6 +121,7 @@ module ActionDispatch # a string. # # match 'accounts/:name' => redirect(SubdomainRedirector.new('api')) + # def redirect(*args, &block) options = args.extract_options! status = options.delete(:status) || 301 diff --git a/actionpack/lib/action_dispatch/routing/route_set.rb b/actionpack/lib/action_dispatch/routing/route_set.rb index c5601a82d6..0ae668d42a 100644 --- a/actionpack/lib/action_dispatch/routing/route_set.rb +++ b/actionpack/lib/action_dispatch/routing/route_set.rb @@ -180,6 +180,7 @@ module ActionDispatch # 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]) diff --git a/actionpack/lib/action_dispatch/routing/url_for.rb b/actionpack/lib/action_dispatch/routing/url_for.rb index 207f56aaea..fd3bed7e8f 100644 --- a/actionpack/lib/action_dispatch/routing/url_for.rb +++ b/actionpack/lib/action_dispatch/routing/url_for.rb @@ -79,6 +79,7 @@ module ActionDispatch # end # # User.find(1).base_uri # => "/users/1" + # module UrlFor extend ActiveSupport::Concern include PolymorphicRoutes diff --git a/actionpack/lib/action_dispatch/testing/assertions/routing.rb b/actionpack/lib/action_dispatch/testing/assertions/routing.rb index 1539b894c9..567ca0c392 100644 --- a/actionpack/lib/action_dispatch/testing/assertions/routing.rb +++ b/actionpack/lib/action_dispatch/testing/assertions/routing.rb @@ -140,6 +140,7 @@ module ActionDispatch # end # end # end + # def with_routing old_routes, @routes = @routes, ActionDispatch::Routing::RouteSet.new if defined?(@controller) && @controller diff --git a/actionpack/lib/action_view/helpers/asset_tag_helpers/stylesheet_tag_helpers.rb b/actionpack/lib/action_view/helpers/asset_tag_helpers/stylesheet_tag_helpers.rb index d7df9ea0d5..57b0627225 100644 --- a/actionpack/lib/action_view/helpers/asset_tag_helpers/stylesheet_tag_helpers.rb +++ b/actionpack/lib/action_view/helpers/asset_tag_helpers/stylesheet_tag_helpers.rb @@ -139,6 +139,7 @@ module ActionView # 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) diff --git a/actionpack/lib/action_view/helpers/capture_helper.rb b/actionpack/lib/action_view/helpers/capture_helper.rb index c1f47a2eac..397738dd98 100644 --- a/actionpack/lib/action_view/helpers/capture_helper.rb +++ b/actionpack/lib/action_view/helpers/capture_helper.rb @@ -33,6 +33,7 @@ module ActionView # # <%= @greeting %> # + # def capture(*args) value = nil buffer = with_output_buffer { value = yield(*args) } diff --git a/actionpack/lib/action_view/helpers/form_helper.rb b/actionpack/lib/action_view/helpers/form_helper.rb index 12576ecd01..fc81bcea80 100644 --- a/actionpack/lib/action_view/helpers/form_helper.rb +++ b/actionpack/lib/action_view/helpers/form_helper.rb @@ -763,6 +763,7 @@ module ActionView # # text_field(:snippet, :code, :size => 20, :class => 'code_input') # # => + # def text_field(object_name, method, options = {}) Tags::TextField.new(object_name, method, self, options).render end @@ -784,6 +785,7 @@ module ActionView # # password_field(: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 @@ module ActionView # # file_field(: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 @@ module ActionView # check_box("eula", "accepted", { :class => 'eula_check' }, "yes", "no") # # => # # + # 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 @@ module ActionView # # telephone_field("user", "phone") # # => + # def telephone_field(object_name, method, options = {}) Tags::TelField.new(object_name, method, self, options).render end @@ -980,6 +985,7 @@ module ActionView # @user.born_on = Date.new(1984, 1, 27) # date_field("user", "born_on", 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 @@ module ActionView # === Example # time_field("task", "started_at") # # => + # def time_field(object_name, method, options = {}) Tags::TimeField.new(object_name, method, self, options).render end @@ -1004,6 +1011,7 @@ module ActionView # # url_field("user", "homepage") # # => + # def url_field(object_name, method, options = {}) Tags::UrlField.new(object_name, method, self, options).render end @@ -1012,6 +1020,7 @@ module ActionView # # email_field("user", "address") # # => + # def email_field(object_name, method, options = {}) Tags::EmailField.new(object_name, method, self, options).render end @@ -1191,6 +1200,7 @@ module ActionView # 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 @@ module ActionView # submit: # post: # create: "Add %{model}" + # def button(value=nil, options={}) value, options = nil, value if value.is_a?(Hash) value ||= submit_default_value diff --git a/actionpack/lib/action_view/helpers/form_options_helper.rb b/actionpack/lib/action_view/helpers/form_options_helper.rb index 90fa1f3520..eef426703d 100644 --- a/actionpack/lib/action_view/helpers/form_options_helper.rb +++ b/actionpack/lib/action_view/helpers/form_options_helper.rb @@ -98,6 +98,7 @@ module ActionView # # # + # module FormOptionsHelper # ERB::Util can mask some helpers like textilize. Make sure to include them. include TextHelper @@ -153,6 +154,7 @@ module ActionView # 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 :include_blank => false 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 @@ module ActionView # # # + # 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 diff --git a/actionpack/lib/action_view/helpers/form_tag_helper.rb b/actionpack/lib/action_view/helpers/form_tag_helper.rb index 07453c4b50..e65b4e3e95 100644 --- a/actionpack/lib/action_view/helpers/form_tag_helper.rb +++ b/actionpack/lib/action_view/helpers/form_tag_helper.rb @@ -63,6 +63,7 @@ module ActionView # # 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 @@ module ActionView # # submit_tag "Save", :confirm => "Are you sure?" # # => + # def submit_tag(value = "Save changes", options = {}) options = options.stringify_keys @@ -444,6 +446,7 @@ module ActionView # # => + # def button_tag(content_or_options = nil, options = nil, &block) options = content_or_options if block_given? && content_or_options.is_a?(Hash) options ||= {} diff --git a/actionpack/lib/action_view/helpers/number_helper.rb b/actionpack/lib/action_view/helpers/number_helper.rb index 9e43a1faf1..dfc26acfad 100644 --- a/actionpack/lib/action_view/helpers/number_helper.rb +++ b/actionpack/lib/action_view/helpers/number_helper.rb @@ -514,6 +514,7 @@ module ActionView # 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 diff --git a/actionpack/lib/action_view/helpers/output_safety_helper.rb b/actionpack/lib/action_view/helpers/output_safety_helper.rb index 891dd859fa..2e7e9dc50c 100644 --- a/actionpack/lib/action_view/helpers/output_safety_helper.rb +++ b/actionpack/lib/action_view/helpers/output_safety_helper.rb @@ -26,6 +26,7 @@ module ActionView #:nodoc: # # safe_join(["

    foo

    ".html_safe, "

    bar

    ".html_safe], "
    ".html_safe) # # => "

    foo


    bar

    " + # def safe_join(array, sep=$,) sep = ERB::Util.html_escape(sep) diff --git a/actionpack/lib/action_view/helpers/record_tag_helper.rb b/actionpack/lib/action_view/helpers/record_tag_helper.rb index 8734136f39..9b35f076e5 100644 --- a/actionpack/lib/action_view/helpers/record_tag_helper.rb +++ b/actionpack/lib/action_view/helpers/record_tag_helper.rb @@ -29,6 +29,7 @@ module ActionView # #
    Joe Bloggs
    #
    Jane Bloggs
    + # def div_for(record, *args, &block) content_tag_for(:div, record, *args, &block) end @@ -78,6 +79,7 @@ module ActionView # produces: # #
  • ... + # def content_tag_for(tag_name, single_or_multiple_records, prefix = nil, options = nil, &block) options, prefix = prefix, nil if prefix.is_a?(Hash) diff --git a/actionpack/lib/action_view/helpers/rendering_helper.rb b/actionpack/lib/action_view/helpers/rendering_helper.rb index 55fb443929..626e1a1ab7 100644 --- a/actionpack/lib/action_view/helpers/rendering_helper.rb +++ b/actionpack/lib/action_view/helpers/rendering_helper.rb @@ -75,6 +75,7 @@ module ActionView # # Hello David # + # def _layout_for(*args, &block) name = args.first diff --git a/actionpack/lib/action_view/helpers/sanitize_helper.rb b/actionpack/lib/action_view/helpers/sanitize_helper.rb index ba74217c12..a727b910e5 100644 --- a/actionpack/lib/action_view/helpers/sanitize_helper.rb +++ b/actionpack/lib/action_view/helpers/sanitize_helper.rb @@ -55,6 +55,7 @@ module ActionView # 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 @@ module ActionView # 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 @@ module ActionView # 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 @@ module ActionView # 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 @@ module ActionView # 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 @@ module ActionView # 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 @@ module ActionView # 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 @@ module ActionView # 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 @@ module ActionView # 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 @@ module ActionView # 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 @@ module ActionView # 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 @@ module ActionView # 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 diff --git a/actionpack/lib/action_view/helpers/tags/select.rb b/actionpack/lib/action_view/helpers/tags/select.rb index 4d94ee2c23..53a108b7e6 100644 --- a/actionpack/lib/action_view/helpers/tags/select.rb +++ b/actionpack/lib/action_view/helpers/tags/select.rb @@ -31,6 +31,7 @@ module ActionView # # [nil, []] # { nil => [] } + # def grouped_choices? !@choices.empty? && @choices.first.respond_to?(:last) && Array === @choices.first.last end diff --git a/actionpack/lib/action_view/helpers/url_helper.rb b/actionpack/lib/action_view/helpers/url_helper.rb index 2e45a2ae0f..7e69547dab 100644 --- a/actionpack/lib/action_view/helpers/url_helper.rb +++ b/actionpack/lib/action_view/helpers/url_helper.rb @@ -586,6 +586,7 @@ module ActionView # # current_page?(:controller => 'product', :action => 'index') # # => false + # def current_page?(options) unless request raise "You cannot use helpers that need to determine the current " \ diff --git a/actionpack/lib/action_view/template/resolver.rb b/actionpack/lib/action_view/template/resolver.rb index d267a8466a..fa2038f78d 100644 --- a/actionpack/lib/action_view/template/resolver.rb +++ b/actionpack/lib/action_view/template/resolver.rb @@ -215,6 +215,7 @@ module ActionView # * :locale - possible locale versions # * :formats - possible request formats (for example html, json, xml...) # * :handlers - 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) diff --git a/activemodel/lib/active_model/attribute_methods.rb b/activemodel/lib/active_model/attribute_methods.rb index 61985e241b..99918fdb96 100644 --- a/activemodel/lib/active_model/attribute_methods.rb +++ b/activemodel/lib/active_model/attribute_methods.rb @@ -53,6 +53,7 @@ module ActiveModel # hash value. # # Hash keys must be strings. + # module AttributeMethods extend ActiveSupport::Concern diff --git a/activemodel/lib/active_model/callbacks.rb b/activemodel/lib/active_model/callbacks.rb index 50709e5ee1..ebb4b51aa3 100644 --- a/activemodel/lib/active_model/callbacks.rb +++ b/activemodel/lib/active_model/callbacks.rb @@ -83,6 +83,7 @@ module ActiveModel # # obj is the MyModel instance that the callback is being called on # end # end + # def define_model_callbacks(*callbacks) options = callbacks.extract_options! options = { diff --git a/activemodel/lib/active_model/conversion.rb b/activemodel/lib/active_model/conversion.rb index cea11c1a18..d7f30f0920 100644 --- a/activemodel/lib/active_model/conversion.rb +++ b/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 diff --git a/activemodel/lib/active_model/errors.rb b/activemodel/lib/active_model/errors.rb index 7b311a50ff..aba6618b56 100644 --- a/activemodel/lib/active_model/errors.rb +++ b/activemodel/lib/active_model/errors.rb @@ -317,6 +317,7 @@ module ActiveModel # * activemodel.errors.messages.blank # * errors.attributes.title.blank # * errors.messages.blank + # def generate_message(attribute, type = :invalid, options = {}) type = options.delete(:message) if options[:message].is_a?(Symbol) diff --git a/activemodel/lib/active_model/lint.rb b/activemodel/lib/active_model/lint.rb index 2c7f2a9334..88b730626c 100644 --- a/activemodel/lib/active_model/lint.rb +++ b/activemodel/lib/active_model/lint.rb @@ -52,6 +52,7 @@ module ActiveModel # # 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 @@ module ActiveModel # # 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 diff --git a/activemodel/lib/active_model/mass_assignment_security.rb b/activemodel/lib/active_model/mass_assignment_security.rb index 50951b28d9..893fbf92c3 100644 --- a/activemodel/lib/active_model/mass_assignment_security.rb +++ b/activemodel/lib/active_model/mass_assignment_security.rb @@ -56,6 +56,8 @@ module ActiveModel # # You can specify your own sanitizer object eg. MySanitizer.new. # See ActiveModel::MassAssignmentSecurity::LoggerSanitizer 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 diff --git a/activemodel/lib/active_model/observing.rb b/activemodel/lib/active_model/observing.rb index 117c19c412..f5ea285ccb 100644 --- a/activemodel/lib/active_model/observing.rb +++ b/activemodel/lib/active_model/observing.rb @@ -124,6 +124,7 @@ module ActiveModel # # 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 @@ module ActiveModel # 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 diff --git a/activemodel/lib/active_model/serialization.rb b/activemodel/lib/active_model/serialization.rb index 5fabfb7219..6d8fd21814 100644 --- a/activemodel/lib/active_model/serialization.rb +++ b/activemodel/lib/active_model/serialization.rb @@ -115,6 +115,7 @@ module ActiveModel # @data[key] # end # end + # alias :read_attribute_for_serialization :send # Add associations specified via the :include option. diff --git a/activemodel/lib/active_model/validations.rb b/activemodel/lib/active_model/validations.rb index 019d4b22cf..611e9ffd55 100644 --- a/activemodel/lib/active_model/validations.rb +++ b/activemodel/lib/active_model/validations.rb @@ -38,6 +38,7 @@ module ActiveModel # Note that ActiveModel::Validations automatically adds an +errors+ method # to your instances initialized with a new ActiveModel::Errors object, so # there is no need for you to do this manually. + # module Validations extend ActiveSupport::Concern @@ -221,6 +222,7 @@ module ActiveModel # @data[key] # end # end + # alias :read_attribute_for_validation :send protected diff --git a/activemodel/lib/active_model/validations/validates.rb b/activemodel/lib/active_model/validations/validates.rb index b6a1cfcf41..d94c4e3f4f 100644 --- a/activemodel/lib/active_model/validations/validates.rb +++ b/activemodel/lib/active_model/validations/validates.rb @@ -77,6 +77,7 @@ module ActiveModel # 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) diff --git a/activemodel/lib/active_model/validator.rb b/activemodel/lib/active_model/validator.rb index de1a271dde..2953126c3c 100644 --- a/activemodel/lib/active_model/validator.rb +++ b/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 validates_with method. + # class Validator attr_reader :options @@ -101,6 +102,7 @@ module ActiveModel #:nodoc: # # PresenceValidator.kind # => :presence # UniquenessValidator.kind # => :uniqueness + # def self.kind @kind ||= name.split('::').last.underscore.sub(/_validator$/, '').to_sym unless anonymous? end diff --git a/activemodel/test/cases/validations/i18n_validation_test.rb b/activemodel/test/cases/validations/i18n_validation_test.rb index 0ea9f5393d..6b6aad3bd1 100644 --- a/activemodel/test/cases/validations/i18n_validation_test.rb +++ b/activemodel/test/cases/validations/i18n_validation_test.rb @@ -65,6 +65,7 @@ class I18nValidationTest < ActiveModel::TestCase # 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", {}, {}], diff --git a/activerecord/lib/active_record/aggregations.rb b/activerecord/lib/active_record/aggregations.rb index e0392c5a48..6ad16bee2b 100644 --- a/activerecord/lib/active_record/aggregations.rb +++ b/activerecord/lib/active_record/aggregations.rb @@ -166,6 +166,7 @@ module ActiveRecord # 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: # composed_of :address adds address and address=(new_address) methods. @@ -206,6 +207,7 @@ module ActiveRecord # :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) diff --git a/activerecord/lib/active_record/associations/association.rb b/activerecord/lib/active_record/associations/association.rb index 57d602fd83..e75003f261 100644 --- a/activerecord/lib/active_record/associations/association.rb +++ b/activerecord/lib/active_record/associations/association.rb @@ -34,6 +34,7 @@ module ActiveRecord # Returns the name of the table of the related class: # # post.comments.aliased_table_name # => "comments" + # def aliased_table_name klass.table_name end diff --git a/activerecord/lib/active_record/callbacks.rb b/activerecord/lib/active_record/callbacks.rb index fe18a5d5aa..a050fabf35 100644 --- a/activerecord/lib/active_record/callbacks.rb +++ b/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 diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb index 95ab375951..df78ba6c5a 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_definitions.rb @@ -339,6 +339,7 @@ module ActiveRecord # t.remove_index # t.remove_timestamps # end + # class Table def initialize(table_name, base) @table_name = table_name diff --git a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb index e2eb72fdd6..62b0f51bb2 100644 --- a/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb +++ b/activerecord/lib/active_record/connection_adapters/abstract/schema_statements.rb @@ -380,6 +380,7 @@ module ActiveRecord # 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}" diff --git a/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb b/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb index 3d6ab72e07..0b6734b010 100644 --- a/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/mysql_adapter.rb @@ -59,6 +59,7 @@ module ActiveRecord # * :sslcert - Necessary to use MySQL with an SSL connection. # * :sslcapath - Necessary to use MySQL with an SSL connection. # * :sslcipher - Necessary to use MySQL with an SSL connection. + # class MysqlAdapter < AbstractMysqlAdapter class Column < AbstractMysqlAdapter::Column #:nodoc: diff --git a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb index ad7c4025cf..14bc95abfe 100644 --- a/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/postgresql_adapter.rb @@ -684,6 +684,7 @@ module ActiveRecord # -> 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) diff --git a/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb b/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb index 25ec88c9c5..d4ffa82b17 100644 --- a/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb +++ b/activerecord/lib/active_record/connection_adapters/sqlite3_adapter.rb @@ -265,6 +265,7 @@ module ActiveRecord # # 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('|') diff --git a/activerecord/lib/active_record/locking/optimistic.rb b/activerecord/lib/active_record/locking/optimistic.rb index 604da5a4fd..a3412582fa 100644 --- a/activerecord/lib/active_record/locking/optimistic.rb +++ b/activerecord/lib/active_record/locking/optimistic.rb @@ -46,6 +46,7 @@ module ActiveRecord # class Person < ActiveRecord::Base # self.locking_column = :lock_person # end + # module Optimistic extend ActiveSupport::Concern diff --git a/activerecord/lib/active_record/model.rb b/activerecord/lib/active_record/model.rb index 5906a57828..105d1e0e2b 100644 --- a/activerecord/lib/active_record/model.rb +++ b/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 diff --git a/activerecord/lib/active_record/observer.rb b/activerecord/lib/active_record/observer.rb index 2467edcc53..fdf17c003c 100644 --- a/activerecord/lib/active_record/observer.rb +++ b/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 ModelObserver.instance before. Observers are # singletons and that call instantiates and registers them. + # class Observer < ActiveModel::Observer protected diff --git a/activerecord/lib/active_record/persistence.rb b/activerecord/lib/active_record/persistence.rb index daf5936a2d..a1bc39a32d 100644 --- a/activerecord/lib/active_record/persistence.rb +++ b/activerecord/lib/active_record/persistence.rb @@ -158,6 +158,7 @@ module ActiveRecord # * 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) diff --git a/activerecord/lib/active_record/reflection.rb b/activerecord/lib/active_record/reflection.rb index 17e388a1d4..c380b5c029 100644 --- a/activerecord/lib/active_record/reflection.rb +++ b/activerecord/lib/active_record/reflection.rb @@ -42,6 +42,7 @@ module ActiveRecord # 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 @@ module ActiveRecord # # 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 @@ module ActiveRecord # # 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 @@ module ActiveRecord # 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 @@ module ActiveRecord # # 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 @@ module ActiveRecord # Gets an array of possible :through 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 diff --git a/activerecord/lib/active_record/relation/calculations.rb b/activerecord/lib/active_record/relation/calculations.rb index 75d983d3b8..31d99f0192 100644 --- a/activerecord/lib/active_record/relation/calculations.rb +++ b/activerecord/lib/active_record/relation/calculations.rb @@ -138,6 +138,7 @@ module ActiveRecord # 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}" diff --git a/activerecord/lib/active_record/relation/finder_methods.rb b/activerecord/lib/active_record/relation/finder_methods.rb index 9d62e726d4..4fedd33d64 100644 --- a/activerecord/lib/active_record/relation/finder_methods.rb +++ b/activerecord/lib/active_record/relation/finder_methods.rb @@ -49,6 +49,7 @@ module ActiveRecord # # Post.find_by name: 'Spartacus', rating: 4 # Post.find_by "published_at < ?", 2.weeks.ago + # def find_by(*args) where(*args).take end diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb index c086386da6..19fe8155d9 100644 --- a/activerecord/lib/active_record/relation/query_methods.rb +++ b/activerecord/lib/active_record/relation/query_methods.rb @@ -163,6 +163,7 @@ module ActiveRecord # 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 @@ module ActiveRecord # Post.none # => returning [] instead breaks the previous code # end # end + # def none NullRelation.new(@klass, @table) end @@ -310,6 +312,7 @@ module ActiveRecord # # 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 diff --git a/activerecord/lib/active_record/relation/spawn_methods.rb b/activerecord/lib/active_record/relation/spawn_methods.rb index 4fb1cb6726..80d087a9ea 100644 --- a/activerecord/lib/active_record/relation/spawn_methods.rb +++ b/activerecord/lib/active_record/relation/spawn_methods.rb @@ -23,6 +23,7 @@ module ActiveRecord # 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 @@ module ActiveRecord # # 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 @@ module ActiveRecord # # 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 diff --git a/activerecord/lib/active_record/validations/uniqueness.rb b/activerecord/lib/active_record/validations/uniqueness.rb index c1a72ea8b3..9e4b588ac2 100644 --- a/activerecord/lib/active_record/validations/uniqueness.rb +++ b/activerecord/lib/active_record/validations/uniqueness.rb @@ -198,6 +198,7 @@ module ActiveRecord # * ActiveRecord::ConnectionAdapters::Mysql2Adapter # * ActiveRecord::ConnectionAdapters::SQLite3Adapter # * ActiveRecord::ConnectionAdapters::PostgreSQLAdapter + # def validates_uniqueness_of(*attr_names) validates_with UniquenessValidator, _merge_attributes(attr_names) end diff --git a/activerecord/test/cases/attribute_methods_test.rb b/activerecord/test/cases/attribute_methods_test.rb index eef1366a6d..1093fedea1 100644 --- a/activerecord/test/cases/attribute_methods_test.rb +++ b/activerecord/test/cases/attribute_methods_test.rb @@ -719,6 +719,7 @@ class AttributeMethodsTest < ActiveRecord::TestCase 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 diff --git a/activerecord/test/cases/validations/i18n_validation_test.rb b/activerecord/test/cases/validations/i18n_validation_test.rb index 89b92e0b13..15b97c02c8 100644 --- a/activerecord/test/cases/validations/i18n_validation_test.rb +++ b/activerecord/test/cases/validations/i18n_validation_test.rb @@ -33,6 +33,7 @@ class I18nValidationTest < ActiveRecord::TestCase # 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", {}, {}], diff --git a/activerecord/test/models/subject.rb b/activerecord/test/models/subject.rb index 6bf45ba5b2..8e28f8b86b 100644 --- a/activerecord/test/models/subject.rb +++ b/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 diff --git a/activesupport/lib/active_support/benchmarkable.rb b/activesupport/lib/active_support/benchmarkable.rb index a39fa016ec..f149a7f0ed 100644 --- a/activesupport/lib/active_support/benchmarkable.rb +++ b/activesupport/lib/active_support/benchmarkable.rb @@ -44,6 +44,7 @@ module ActiveSupport end # Silence the logger during the execution of the block. + # def silence old_logger_level, logger.level = logger.level, ::Logger::ERROR if logger yield diff --git a/activesupport/lib/active_support/callbacks.rb b/activesupport/lib/active_support/callbacks.rb index 9636bbccb5..a9253c186d 100644 --- a/activesupport/lib/active_support/callbacks.rb +++ b/activesupport/lib/active_support/callbacks.rb @@ -341,6 +341,7 @@ module ActiveSupport # 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 : {} diff --git a/activesupport/lib/active_support/concern.rb b/activesupport/lib/active_support/concern.rb index 9450d4ea88..c94a8d99f4 100644 --- a/activesupport/lib/active_support/concern.rb +++ b/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", []) diff --git a/activesupport/lib/active_support/configurable.rb b/activesupport/lib/active_support/configurable.rb index afd56cb7ce..a8aa53a80f 100644 --- a/activesupport/lib/active_support/configurable.rb +++ b/activesupport/lib/active_support/configurable.rb @@ -48,6 +48,7 @@ module ActiveSupport # user = User.new # user.allowed_access = true # user.allowed_access # => true + # def config_accessor(*names) options = names.extract_options! @@ -78,6 +79,7 @@ module ActiveSupport # # user.config.allowed_access # => true # user.config.level # => 1 + # def config @_config ||= self.class.config.inheritable_copy end diff --git a/activesupport/lib/active_support/core_ext/array/conversions.rb b/activesupport/lib/active_support/core_ext/array/conversions.rb index 193388a158..24aa28b895 100644 --- a/activesupport/lib/active_support/core_ext/array/conversions.rb +++ b/activesupport/lib/active_support/core_ext/array/conversions.rb @@ -136,6 +136,7 @@ class Array # 1 # # + # def to_xml(options = {}) require 'active_support/builder' unless defined?(Builder) diff --git a/activesupport/lib/active_support/core_ext/array/uniq_by.rb b/activesupport/lib/active_support/core_ext/array/uniq_by.rb index c1d5a355a4..3bedfa9a61 100644 --- a/activesupport/lib/active_support/core_ext/array/uniq_by.rb +++ b/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) diff --git a/activesupport/lib/active_support/core_ext/enumerable.rb b/activesupport/lib/active_support/core_ext/enumerable.rb index b950826396..02d5a7080f 100644 --- a/activesupport/lib/active_support/core_ext/enumerable.rb +++ b/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 @@ module Enumerable # => { "nextangle" => , "chade-" => , ...} # people.index_by { |person| "#{person.first_name} #{person.last_name}" } # => { "Chade- Fowlersburg-e" => , "David Heinemeier Hansson" => , ...} + # def index_by if block_given? Hash[map { |elem| [yield(elem), elem] }] diff --git a/activesupport/lib/active_support/core_ext/hash/except.rb b/activesupport/lib/active_support/core_ext/hash/except.rb index fafd4919b9..5a61906222 100644 --- a/activesupport/lib/active_support/core_ext/hash/except.rb +++ b/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 diff --git a/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb b/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb index c1f368d0eb..7d54c9fae6 100644 --- a/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb +++ b/activesupport/lib/active_support/core_ext/hash/indifferent_access.rb @@ -5,6 +5,7 @@ class Hash # Returns an ActiveSupport::HashWithIndifferentAccess 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 @@ class Hash # # b = {:b => 1} # {:a => b}.with_indifferent_access["a"] # calls b.nested_under_indifferent_access + # alias nested_under_indifferent_access with_indifferent_access end diff --git a/activesupport/lib/active_support/core_ext/integer/inflections.rb b/activesupport/lib/active_support/core_ext/integer/inflections.rb index 56f2ed5985..1e30687166 100644 --- a/activesupport/lib/active_support/core_ext/integer/inflections.rb +++ b/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 @@ class Integer # 1003.ordinal # => "rd" # -11.ordinal # => "th" # -1001.ordinal # => "st" + # def ordinal ActiveSupport::Inflector.ordinal(self) end diff --git a/activesupport/lib/active_support/core_ext/kernel/reporting.rb b/activesupport/lib/active_support/core_ext/kernel/reporting.rb index 728069a9a8..ad3f9ebec9 100644 --- a/activesupport/lib/active_support/core_ext/kernel/reporting.rb +++ b/activesupport/lib/active_support/core_ext/kernel/reporting.rb @@ -65,6 +65,7 @@ module Kernel # # stream = capture(:stdout) { puts 'Cool' } # stream # => "Cool\n" + # def capture(stream) begin stream = stream.to_s @@ -82,6 +83,7 @@ module Kernel # Silences both STDOUT and STDERR, even for subprocesses. # # quietly { system 'bundle install' } + # def quietly silence_stream(STDOUT) do silence_stream(STDERR) do diff --git a/activesupport/lib/active_support/core_ext/module/anonymous.rb b/activesupport/lib/active_support/core_ext/module/anonymous.rb index b0c7b021db..0a9e791030 100644 --- a/activesupport/lib/active_support/core_ext/module/anonymous.rb +++ b/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 diff --git a/activesupport/lib/active_support/core_ext/module/delegation.rb b/activesupport/lib/active_support/core_ext/module/delegation.rb index 30acc87c4a..fbef27c76a 100644 --- a/activesupport/lib/active_support/core_ext/module/delegation.rb +++ b/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] diff --git a/activesupport/lib/active_support/core_ext/module/introspection.rb b/activesupport/lib/active_support/core_ext/module/introspection.rb index 649a969149..3c8e811fa4 100644 --- a/activesupport/lib/active_support/core_ext/module/introspection.rb +++ b/activesupport/lib/active_support/core_ext/module/introspection.rb @@ -27,6 +27,7 @@ class Module # # M.parent # => Object # Module.new.parent # => Object + # def parent parent_name ? ActiveSupport::Inflector.constantize(parent_name) : Object end @@ -43,6 +44,7 @@ class Module # M.parents # => [Object] # M::N.parents # => [M, Object] # X.parents # => [M, Object] + # def parents parents = [] if parent_name diff --git a/activesupport/lib/active_support/core_ext/object/blank.rb b/activesupport/lib/active_support/core_ext/object/blank.rb index 09d9af1bde..e238fef5a2 100644 --- a/activesupport/lib/active_support/core_ext/object/blank.rb +++ b/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 diff --git a/activesupport/lib/active_support/core_ext/object/duplicable.rb b/activesupport/lib/active_support/core_ext/object/duplicable.rb index 9cd7485e2e..f1b755c2c4 100644 --- a/activesupport/lib/active_support/core_ext/object/duplicable.rb +++ b/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 diff --git a/activesupport/lib/active_support/core_ext/object/with_options.rb b/activesupport/lib/active_support/core_ext/object/with_options.rb index 723bf69189..e058367111 100644 --- a/activesupport/lib/active_support/core_ext/object/with_options.rb +++ b/activesupport/lib/active_support/core_ext/object/with_options.rb @@ -36,6 +36,7 @@ class Object # # with_options 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 diff --git a/activesupport/lib/active_support/core_ext/string/inflections.rb b/activesupport/lib/active_support/core_ext/string/inflections.rb index e726a475e0..070bfd7af6 100644 --- a/activesupport/lib/active_support/core_ext/string/inflections.rb +++ b/activesupport/lib/active_support/core_ext/string/inflections.rb @@ -5,6 +5,7 @@ require 'active_support/inflector/transliterate' # 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. # diff --git a/activesupport/lib/active_support/core_ext/string/output_safety.rb b/activesupport/lib/active_support/core_ext/string/output_safety.rb index d4e1597840..5226ff0cbe 100644 --- a/activesupport/lib/active_support/core_ext/string/output_safety.rb +++ b/activesupport/lib/active_support/core_ext/string/output_safety.rb @@ -64,6 +64,7 @@ class ERB # 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 diff --git a/activesupport/lib/active_support/file_update_checker.rb b/activesupport/lib/active_support/file_update_checker.rb index 20dde73abf..8860636168 100644 --- a/activesupport/lib/active_support/file_update_checker.rb +++ b/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 diff --git a/activesupport/lib/active_support/hash_with_indifferent_access.rb b/activesupport/lib/active_support/hash_with_indifferent_access.rb index 3191a3bdc6..91459f3e5b 100644 --- a/activesupport/lib/active_support/hash_with_indifferent_access.rb +++ b/activesupport/lib/active_support/hash_with_indifferent_access.rb @@ -53,6 +53,7 @@ module ActiveSupport # # hash = HashWithIndifferentAccess.new # hash[:key] = "value" + # def []=(key, value) regular_writer(convert_key(key), convert_value(value)) end @@ -68,6 +69,7 @@ module ActiveSupport # 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 @@ module ActiveSupport # hash["key"] = "value" # hash.key? :key # => true # hash.key? "key" # => true + # def key?(key) super(convert_key(key)) end @@ -104,6 +107,7 @@ module ActiveSupport # 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 diff --git a/activesupport/lib/active_support/inflector/methods.rb b/activesupport/lib/active_support/inflector/methods.rb index 53a1c3f160..48296841aa 100644 --- a/activesupport/lib/active_support/inflector/methods.rb +++ b/activesupport/lib/active_support/inflector/methods.rb @@ -228,6 +228,7 @@ module ActiveSupport # "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) diff --git a/activesupport/lib/active_support/lazy_load_hooks.rb b/activesupport/lib/active_support/lazy_load_hooks.rb index 34450c65d4..c167efc1a7 100644 --- a/activesupport/lib/active_support/lazy_load_hooks.rb +++ b/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] = [] } diff --git a/activesupport/lib/active_support/log_subscriber.rb b/activesupport/lib/active_support/log_subscriber.rb index 20ca6ff5f6..d2a6e1bd82 100644 --- a/activesupport/lib/active_support/log_subscriber.rb +++ b/activesupport/lib/active_support/log_subscriber.rb @@ -111,6 +111,7 @@ module ActiveSupport # 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) diff --git a/activesupport/lib/active_support/log_subscriber/test_helper.rb b/activesupport/lib/active_support/log_subscriber/test_helper.rb index 5c7a238934..b65ea6208c 100644 --- a/activesupport/lib/active_support/log_subscriber/test_helper.rb +++ b/activesupport/lib/active_support/log_subscriber/test_helper.rb @@ -31,6 +31,7 @@ module ActiveSupport # 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 @@ module ActiveSupport # def logger # ActiveRecord::Base.logger = @logger # end + # def set_logger(logger) ActiveSupport::LogSubscriber.logger = logger end diff --git a/activesupport/lib/active_support/message_encryptor.rb b/activesupport/lib/active_support/message_encryptor.rb index c002b1c02c..ada2e79ccb 100644 --- a/activesupport/lib/active_support/message_encryptor.rb +++ b/activesupport/lib/active_support/message_encryptor.rb @@ -36,6 +36,7 @@ module ActiveSupport # Options: # * :cipher - Cipher to use. Can be any cipher returned by OpenSSL::Cipher.ciphers. Default is 'aes-256-cbc' # * :serializer - Object serializer to use. Default is +Marshal+. + # def initialize(secret, options = {}) @secret = secret @cipher = options[:cipher] || 'aes-256-cbc' diff --git a/activesupport/lib/active_support/notifications.rb b/activesupport/lib/active_support/notifications.rb index 6d89307638..6735c561d3 100644 --- a/activesupport/lib/active_support/notifications.rb +++ b/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) } diff --git a/activesupport/lib/active_support/ordered_options.rb b/activesupport/lib/active_support/ordered_options.rb index 6bd6f1f2ff..60e6cd55ad 100644 --- a/activesupport/lib/active_support/ordered_options.rb +++ b/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 diff --git a/activesupport/lib/active_support/string_inquirer.rb b/activesupport/lib/active_support/string_inquirer.rb index e059594bfa..f3f3909a90 100644 --- a/activesupport/lib/active_support/string_inquirer.rb +++ b/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] == "?" diff --git a/activesupport/lib/active_support/time_with_zone.rb b/activesupport/lib/active_support/time_with_zone.rb index f040ee7101..451520ac5c 100644 --- a/activesupport/lib/active_support/time_with_zone.rb +++ b/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 @@ module ActiveSupport # # 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 diff --git a/railties/lib/rails/application.rb b/railties/lib/rails/application.rb index 6cd2c425c3..c4edbae55b 100644 --- a/railties/lib/rails/application.rb +++ b/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' diff --git a/railties/lib/rails/configuration.rb b/railties/lib/rails/configuration.rb index 57168eee83..3d66019e5e 100644 --- a/railties/lib/rails/configuration.rb +++ b/railties/lib/rails/configuration.rb @@ -32,6 +32,7 @@ module Rails # And finally they can also be removed from the stack completely: # # config.middleware.delete ActionDispatch::BestStandardsSupport + # class MiddlewareStackProxy def initialize @operations = [] diff --git a/railties/lib/rails/engine/configuration.rb b/railties/lib/rails/engine/configuration.rb index f4de5a4375..d3b42021fc 100644 --- a/railties/lib/rails/engine/configuration.rb +++ b/railties/lib/rails/engine/configuration.rb @@ -28,6 +28,7 @@ module Rails # 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? diff --git a/railties/lib/rails/generators/active_model.rb b/railties/lib/rails/generators/active_model.rb index 3d3b50540a..454327f765 100644 --- a/railties/lib/rails/generators/active_model.rb +++ b/railties/lib/rails/generators/active_model.rb @@ -22,6 +22,7 @@ module Rails # # The only exception in ActiveModel for ActiveRecord is the use of self.build # instead of self.new. + # class ActiveModel attr_reader :name diff --git a/railties/lib/rails/generators/base.rb b/railties/lib/rails/generators/base.rb index f2ded6be84..28d7680669 100644 --- a/railties/lib/rails/generators/base.rb +++ b/railties/lib/rails/generators/base.rb @@ -161,6 +161,7 @@ module Rails # 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 diff --git a/railties/lib/rails/generators/named_base.rb b/railties/lib/rails/generators/named_base.rb index e02f19508f..e85d1b8fa2 100644 --- a/railties/lib/rails/generators/named_base.rb +++ b/railties/lib/rails/generators/named_base.rb @@ -168,6 +168,7 @@ module Rails # # 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 diff --git a/railties/lib/rails/generators/resource_helpers.rb b/railties/lib/rails/generators/resource_helpers.rb index 3c12da359b..48833869e5 100644 --- a/railties/lib/rails/generators/resource_helpers.rb +++ b/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 @@ module Rails end # Set controller variables on initialization. + # def initialize(*args) #:nodoc: super diff --git a/railties/lib/rails/generators/test_case.rb b/railties/lib/rails/generators/test_case.rb index e8f5925ca5..ff9cf0087e 100644 --- a/railties/lib/rails/generators/test_case.rb +++ b/railties/lib/rails/generators/test_case.rb @@ -26,6 +26,7 @@ module Rails # destination File.expand_path("../tmp", File.dirname(__FILE__)) # setup :prepare_destination # end + # class TestCase < ActiveSupport::TestCase include FileUtils @@ -42,6 +43,7 @@ module Rails # Sets which generator should be tested: # # tests AppGenerator + # def self.tests(klass) self.generator_class = klass end @@ -50,6 +52,7 @@ module Rails # invoking it. # # arguments %w(app_name --skip-active-record) + # def self.arguments(array) self.default_arguments = array end @@ -57,6 +60,7 @@ module Rails # Sets the destination of generator files: # # destination File.expand_path("../tmp", File.dirname(__FILE__)) + # def self.destination(path) self.destination_root = path end @@ -79,6 +83,7 @@ module Rails # assert_match(/Product\.all/, index) # end # end + # def assert_file(relative, *contents) absolute = File.expand_path(relative, destination_root) assert File.exists?(absolute), "Expected file #{relative.inspect} to exist, but does not" @@ -101,6 +106,7 @@ module Rails # path relative to the configured destination: # # assert_no_file "config/random.rb" + # def assert_no_file(relative) absolute = File.expand_path(relative, destination_root) assert !File.exists?(absolute), "Expected file #{relative.inspect} to not exist, but does" @@ -118,6 +124,7 @@ module Rails # assert_file "db/migrate/003_create_products.rb" # # Consequently, assert_migration accepts the same arguments has assert_file. + # def assert_migration(relative, *contents, &block) file_name = migration_file_name(relative) assert file_name, "Expected migration #{relative} to exist, but was not found" @@ -128,6 +135,7 @@ module Rails # path relative to the configured destination: # # assert_no_migration "db/migrate/create_products.rb" + # def assert_no_migration(relative) file_name = migration_file_name(relative) assert_nil file_name, "Expected migration #{relative} to not exist, but found #{file_name}" @@ -142,6 +150,7 @@ module Rails # assert_match(/create_table/, up) # end # end + # def assert_class_method(method, content, &block) assert_instance_method "self.#{method}", content, &block end @@ -154,6 +163,7 @@ module Rails # assert_match(/Product\.all/, index) # end # end + # def assert_instance_method(method, content) assert content =~ /def #{method}(\(.+\))?(.*?)\n end/m, "Expected to have method #{method}" yield $2.strip if block_given? @@ -164,6 +174,7 @@ module Rails # properly: # # assert_field_type :date, :date_select + # def assert_field_type(attribute_type, field_type) assert_equal(field_type, create_generated_attribute(attribute_type).field_type) end @@ -171,6 +182,7 @@ module Rails # Asserts the given attribute type gets a proper default value: # # assert_field_default_value :string, "MyString" + # def assert_field_default_value(attribute_type, value) assert_equal(value, create_generated_attribute(attribute_type).default) end @@ -204,6 +216,7 @@ module Rails # attribute type and, optionally, the attribute name: # # create_generated_attribute(:string, 'name') + # def create_generated_attribute(attribute_type, name = 'test', index = nil) Rails::Generators::GeneratedAttribute.parse([name, attribute_type, index].compact.join(':')) end diff --git a/railties/lib/rails/railtie.rb b/railties/lib/rails/railtie.rb index 8fbf58315a..2102f8a03c 100644 --- a/railties/lib/rails/railtie.rb +++ b/railties/lib/rails/railtie.rb @@ -110,6 +110,7 @@ module Rails # can be used in both. # # Be sure to look at the documentation of those specific classes for more information. + # class Railtie autoload :Configurable, "rails/railtie/configurable" autoload :Configuration, "rails/railtie/configuration" diff --git a/railties/test/generators/shared_generator_tests.rb b/railties/test/generators/shared_generator_tests.rb index 6dc72f0fc0..e78e67725d 100644 --- a/railties/test/generators/shared_generator_tests.rb +++ b/railties/test/generators/shared_generator_tests.rb @@ -1,5 +1,6 @@ # # Tests, setup, and teardown common to the application and plugin generator suites. +# module SharedGeneratorTests def setup Rails.application = TestApp::Application -- cgit v1.2.3 From d31b765628db6aa9ffa9a92bfa2401067e92bb6c Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Wed, 23 May 2012 22:49:39 +0530 Subject: Revert "Remove Obsolute root specifiying short syntax" This reverts commit feaa7b35a0214240eb34780ab51b843571e74904. Reason: Incorrect change. That's a Rails 4 feature and will not obviously work in 3.2.3. [ci skip] --- guides/source/routing.textile | 1 + 1 file changed, 1 insertion(+) diff --git a/guides/source/routing.textile b/guides/source/routing.textile index 6081651364..4a50edbb15 100644 --- a/guides/source/routing.textile +++ b/guides/source/routing.textile @@ -629,6 +629,7 @@ You can specify what Rails should route +"/"+ to with the +root+ method: root :to => 'pages#main' +root 'pages#main' # shortcut for the above You should put the +root+ route at the top of the file, because it is the most popular route and should be matched first. You also need to delete the +public/index.html+ file for the root route to take effect. -- cgit v1.2.3 From 1c94868033c631dcb44d705f70433a64d48e0938 Mon Sep 17 00:00:00 2001 From: Vijay Dev Date: Wed, 23 May 2012 23:12:35 +0530 Subject: copy edits in collection proxy docs [ci skip] --- .../active_record/associations/collection_proxy.rb | 43 +++++++++------------- 1 file changed, 18 insertions(+), 25 deletions(-) diff --git a/activerecord/lib/active_record/associations/collection_proxy.rb b/activerecord/lib/active_record/associations/collection_proxy.rb index 6fd5c466f6..100fb38dec 100644 --- a/activerecord/lib/active_record/associations/collection_proxy.rb +++ b/activerecord/lib/active_record/associations/collection_proxy.rb @@ -92,6 +92,10 @@ module ActiveRecord # # ] # # person.pets.select(:name) { |pet| pet.name =~ /oo/ } + # # => [ + # # #, + # # # + # # ] ## # :method: find @@ -113,7 +117,7 @@ module ActiveRecord # # #, # # # # # ] - # + # # person.pets.find(1) # => # # person.pets.find(4) # => ActiveRecord::RecordNotFound: Couldn't find Pet with id=4 # @@ -231,7 +235,7 @@ module ActiveRecord # # Returns a new object of the collection type that has been instantiated with # attributes, linked to this object and that has already been saved (if it - # passed the validations). + # passes the validations). # # class Person # has_many :pets @@ -255,15 +259,14 @@ module ActiveRecord # # #, # # # # # ] - + ## # :method: create! # # :call-seq: # create!(attributes = {}, options = {}, &block) # - # Like +create+, except that if the record is invalid will - # raise an exception. + # Like +create+, except that if the record is invalid, raises an exception. # # class Person # has_many :pets @@ -340,8 +343,8 @@ module ActiveRecord ## # :method: delete_all # - # Deletes all the records from the collection. For +has_many+ it will do the - # deletion according to the strategy specified by the :dependent + # Deletes all the records from the collection. For +has_many+ asssociations, + # the deletion is done according to the strategy specified by the :dependent # option. Returns an array with the deleted records. # # If no :dependent option is given, then it will follow the @@ -501,7 +504,7 @@ module ActiveRecord # You can pass +Fixnum+ or +String+ values, it finds the records # responding to the +id+ and then deletes them from the database. # - # person.pets.size # => 3 + # person.pets.size # => 3 # person.pets # # => [ # # #, @@ -529,7 +532,7 @@ module ActiveRecord # person.pets # => [] # # Pet.find(4, 5, 6) # => ActiveRecord::RecordNotFound: Couldn't find all Pets with IDs (4, 5, 6) - + ## # :method: size # @@ -541,11 +544,7 @@ module ActiveRecord # end # # person.pets.size # => 3 - # # Executes: - # # - # # SELECT COUNT(*) - # # FROM "pets" - # # WHERE "pets"."person_id" = 1 + # # executes something like SELECT COUNT(*) FROM "pets" WHERE "pets"."person_id" = 1 # # person.pets # This will execute a SELECT * FROM query # # => [ @@ -562,24 +561,18 @@ module ActiveRecord # :method: length # # Returns the size of the collection calling +size+ on the target. - # If the collection has been already loaded +length+ and +size+ are - # equivalent. If not and you are going to need the records anyway this - # method will take one less query because loads the collection. Otherwise - # +size+ is more efficient. + # If the collection has been already loaded, +length+ and +size+ are + # equivalent. # # class Person < ActiveRecord::Base # has_many :pets # end # # person.pets.length # => 3 - # # Executes: - # # - # # SELECT "pets".* - # #  FROM "pets" - # # WHERE "pets"."person_id" = 1 + # # executes something like SELECT "pets".* FROM "pets" WHERE "pets"."person_id" = 1 # # # Because the collection is loaded, you can - # # call the collection without execute a query: + # # call the collection with no additional queries: # person.pets # # => [ # # #, @@ -705,7 +698,7 @@ module ActiveRecord :sum, :count, :size, :length, :empty?, :any?, :many?, :include?, :to => :@association - + def initialize(association) @association = association super association.klass, association.klass.arel_table -- cgit v1.2.3