mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Remove blank trailing comments
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.
This commit is contained in:
parent
7eb09aed87
commit
fa6d921e11
105 changed files with 0 additions and 192 deletions
1
Rakefile
1
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|
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -7,7 +7,6 @@ class <%= class_name %> < ActionMailer::Base
|
|||
# with the following lookup:
|
||||
#
|
||||
# en.<%= file_path.tr("/",".") %>.<%= action %>.subject
|
||||
#
|
||||
def <%= action %>
|
||||
@greeting = "Hi"
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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!
|
||||
|
||||
|
|
|
@ -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 <tt>ActionController::Base</tt> to see
|
||||
# other features you can bring into your metal controller.
|
||||
#
|
||||
class Metal < AbstractController::Base
|
||||
abstract!
|
||||
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -52,7 +52,6 @@ module ActionController #:nodoc:
|
|||
end
|
||||
|
||||
# Clear all mime types in <tt>respond_to</tt>.
|
||||
#
|
||||
def clear_respond_to
|
||||
self.mimes_for_respond_to = Hash.new.freeze
|
||||
end
|
||||
|
|
|
@ -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 <code>:edit</code> action for HTML requests with errors, unless
|
||||
# the verb was POST.
|
||||
#
|
||||
def default_action
|
||||
@action ||= DEFAULT_ACTIONS_FOR_VERBS[request.request_method_symbol]
|
||||
end
|
||||
|
|
|
@ -194,7 +194,6 @@ module ActionController #:nodoc:
|
|||
# ==== Passenger
|
||||
#
|
||||
# To be described.
|
||||
#
|
||||
module Streaming
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 <tt>ActionDispatch::Reloader.prepare!</tt>
|
||||
# or <tt>ActionDispatch::Reloader.cleanup!</tt> are called manually.
|
||||
#
|
||||
class Reloader
|
||||
include ActiveSupport::Callbacks
|
||||
|
||||
|
|
|
@ -277,7 +277,6 @@ module ActionDispatch
|
|||
# rake routes
|
||||
#
|
||||
# Target specific controllers by prefixing the command with <tt>CONTROLLER=x</tt>.
|
||||
#
|
||||
module Routing
|
||||
autoload :Mapper, 'action_dispatch/routing/mapper'
|
||||
autoload :RouteSet, 'action_dispatch/routing/route_set'
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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])
|
||||
|
||||
|
|
|
@ -79,7 +79,6 @@ module ActionDispatch
|
|||
# end
|
||||
#
|
||||
# User.find(1).base_uri # => "/users/1"
|
||||
#
|
||||
module UrlFor
|
||||
extend ActiveSupport::Concern
|
||||
include PolymorphicRoutes
|
||||
|
|
|
@ -140,7 +140,6 @@ module ActionDispatch
|
|||
# end
|
||||
# end
|
||||
# end
|
||||
#
|
||||
def with_routing
|
||||
old_routes, @routes = @routes, ActionDispatch::Routing::RouteSet.new
|
||||
if defined?(@controller) && @controller
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -33,7 +33,6 @@ module ActionView
|
|||
# <body>
|
||||
# <b><%= @greeting %></b>
|
||||
# </body></html>
|
||||
#
|
||||
def capture(*args)
|
||||
value = nil
|
||||
buffer = with_output_buffer { value = yield(*args) }
|
||||
|
|
|
@ -763,7 +763,6 @@ module ActionView
|
|||
#
|
||||
# text_field(:snippet, :code, :size => 20, :class => 'code_input')
|
||||
# # => <input type="text" id="snippet_code" name="snippet[code]" size="20" value="#{@snippet.code}" class="code_input" />
|
||||
#
|
||||
def text_field(object_name, method, options = {})
|
||||
Tags::TextField.new(object_name, method, self, options).render
|
||||
end
|
||||
|
@ -785,7 +784,6 @@ module ActionView
|
|||
#
|
||||
# password_field(:account, :pin, :size => 20, :class => 'form_input')
|
||||
# # => <input type="password" id="account_pin" name="account[pin]" size="20" class="form_input" />
|
||||
#
|
||||
def password_field(object_name, method, options = {})
|
||||
Tags::PasswordField.new(object_name, method, self, options).render
|
||||
end
|
||||
|
@ -824,7 +822,6 @@ module ActionView
|
|||
#
|
||||
# file_field(:attachment, :file, :class => 'file_input')
|
||||
# # => <input type="file" id="attachment_file" name="attachment[file]" class="file_input" />
|
||||
#
|
||||
def file_field(object_name, method, options = {})
|
||||
Tags::FileField.new(object_name, method, self, options).render
|
||||
end
|
||||
|
@ -913,7 +910,6 @@ module ActionView
|
|||
# check_box("eula", "accepted", { :class => 'eula_check' }, "yes", "no")
|
||||
# # => <input name="eula[accepted]" type="hidden" value="no" />
|
||||
# # <input type="checkbox" class="eula_check" id="eula_accepted" name="eula[accepted]" value="yes" />
|
||||
#
|
||||
def check_box(object_name, method, options = {}, checked_value = "1", unchecked_value = "0")
|
||||
Tags::CheckBox.new(object_name, method, self, checked_value, unchecked_value, options).render
|
||||
end
|
||||
|
@ -966,7 +962,6 @@ module ActionView
|
|||
#
|
||||
# telephone_field("user", "phone")
|
||||
# # => <input id="user_phone" name="user[phone]" type="tel" />
|
||||
#
|
||||
def telephone_field(object_name, method, options = {})
|
||||
Tags::TelField.new(object_name, method, self, options).render
|
||||
end
|
||||
|
@ -985,7 +980,6 @@ module ActionView
|
|||
# @user.born_on = Date.new(1984, 1, 27)
|
||||
# date_field("user", "born_on", value: "1984-05-12")
|
||||
# # => <input id="user_born_on" name="user[born_on]" type="date" value="1984-05-12" />
|
||||
#
|
||||
def date_field(object_name, method, options = {})
|
||||
Tags::DateField.new(object_name, method, self, options).render
|
||||
end
|
||||
|
@ -1002,7 +996,6 @@ module ActionView
|
|||
# === Example
|
||||
# time_field("task", "started_at")
|
||||
# # => <input id="task_started_at" name="task[started_at]" type="time" />
|
||||
#
|
||||
def time_field(object_name, method, options = {})
|
||||
Tags::TimeField.new(object_name, method, self, options).render
|
||||
end
|
||||
|
@ -1011,7 +1004,6 @@ module ActionView
|
|||
#
|
||||
# url_field("user", "homepage")
|
||||
# # => <input id="user_homepage" name="user[homepage]" type="url" />
|
||||
#
|
||||
def url_field(object_name, method, options = {})
|
||||
Tags::UrlField.new(object_name, method, self, options).render
|
||||
end
|
||||
|
@ -1020,7 +1012,6 @@ module ActionView
|
|||
#
|
||||
# email_field("user", "address")
|
||||
# # => <input id="user_address" name="user[address]" type="email" />
|
||||
#
|
||||
def email_field(object_name, method, options = {})
|
||||
Tags::EmailField.new(object_name, method, self, options).render
|
||||
end
|
||||
|
@ -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
|
||||
|
|
|
@ -98,7 +98,6 @@ module ActionView
|
|||
# <option value="3">Jokes</option>
|
||||
# <option value="4">Poems</option>
|
||||
# </select>
|
||||
#
|
||||
module FormOptionsHelper
|
||||
# ERB::Util can mask some helpers like textilize. Make sure to include them.
|
||||
include TextHelper
|
||||
|
@ -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 <tt>:include_blank => false</tt> option.
|
||||
#
|
||||
def select(object, method, choices, options = {}, html_options = {})
|
||||
Tags::Select.new(object, method, self, choices, options, html_options).render
|
||||
end
|
||||
|
@ -241,7 +239,6 @@ module ActionView
|
|||
# <option value="2">Ireland</option>
|
||||
# </optgroup>
|
||||
# </select>
|
||||
#
|
||||
def grouped_collection_select(object, method, collection, group_method, group_label_method, option_key_method, option_value_method, options = {}, html_options = {})
|
||||
Tags::GroupedCollectionSelect.new(object, method, self, collection, group_method, group_label_method, option_key_method, option_value_method, options, html_options).render
|
||||
end
|
||||
|
|
|
@ -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?"
|
||||
# # => <input name='commit' type='submit' value='Save' data-confirm="Are you sure?" />
|
||||
#
|
||||
def submit_tag(value = "Save changes", options = {})
|
||||
options = options.stringify_keys
|
||||
|
||||
|
@ -446,7 +444,6 @@ module ActionView
|
|||
# # => <button name="button" type="button">
|
||||
# # <strong>Ask me!</strong>
|
||||
# # </button>
|
||||
#
|
||||
def button_tag(content_or_options = nil, options = nil, &block)
|
||||
options = content_or_options if block_given? && content_or_options.is_a?(Hash)
|
||||
options ||= {}
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -26,7 +26,6 @@ module ActionView #:nodoc:
|
|||
#
|
||||
# safe_join(["<p>foo</p>".html_safe, "<p>bar</p>".html_safe], "<br />".html_safe)
|
||||
# # => "<p>foo</p><br /><p>bar</p>"
|
||||
#
|
||||
def safe_join(array, sep=$,)
|
||||
sep = ERB::Util.html_escape(sep)
|
||||
|
||||
|
|
|
@ -29,7 +29,6 @@ module ActionView
|
|||
#
|
||||
# <div id="person_123" class="person foo"> Joe Bloggs </div>
|
||||
# <div id="person_124" class="person foo"> Jane Bloggs </div>
|
||||
#
|
||||
def div_for(record, *args, &block)
|
||||
content_tag_for(:div, record, *args, &block)
|
||||
end
|
||||
|
@ -79,7 +78,6 @@ module ActionView
|
|||
# produces:
|
||||
#
|
||||
# <li id="person_123" class="person bar">...
|
||||
#
|
||||
def content_tag_for(tag_name, single_or_multiple_records, prefix = nil, options = nil, &block)
|
||||
options, prefix = prefix, nil if prefix.is_a?(Hash)
|
||||
|
||||
|
|
|
@ -75,7 +75,6 @@ module ActionView
|
|||
# <html>
|
||||
# Hello David
|
||||
# </html>
|
||||
#
|
||||
def _layout_for(*args, &block)
|
||||
name = args.first
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -31,7 +31,6 @@ module ActionView
|
|||
#
|
||||
# [nil, []]
|
||||
# { nil => [] }
|
||||
#
|
||||
def grouped_choices?
|
||||
!@choices.empty? && @choices.first.respond_to?(:last) && Array === @choices.first.last
|
||||
end
|
||||
|
|
|
@ -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 " \
|
||||
|
|
|
@ -215,7 +215,6 @@ module ActionView
|
|||
# * <tt>:locale</tt> - possible locale versions
|
||||
# * <tt>:formats</tt> - possible request formats (for example html, json, xml...)
|
||||
# * <tt>:handlers</tt> - possible handlers (for example erb, haml, builder...)
|
||||
#
|
||||
class FileSystemResolver < PathResolver
|
||||
def initialize(path, pattern=nil)
|
||||
raise ArgumentError, "path already is a Resolver class" if path.is_a?(Resolver)
|
||||
|
|
|
@ -53,7 +53,6 @@ module ActiveModel
|
|||
# hash value.
|
||||
#
|
||||
# Hash keys must be strings.
|
||||
#
|
||||
module AttributeMethods
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
|
|
|
@ -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 = {
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -317,7 +317,6 @@ module ActiveModel
|
|||
# * <tt>activemodel.errors.messages.blank</tt>
|
||||
# * <tt>errors.attributes.title.blank</tt>
|
||||
# * <tt>errors.messages.blank</tt>
|
||||
#
|
||||
def generate_message(attribute, type = :invalid, options = {})
|
||||
type = options.delete(:message) if options[:message].is_a?(Symbol)
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -56,8 +56,6 @@ module ActiveModel
|
|||
#
|
||||
# You can specify your own sanitizer object eg. MySanitizer.new.
|
||||
# See <tt>ActiveModel::MassAssignmentSecurity::LoggerSanitizer</tt> for example implementation.
|
||||
#
|
||||
#
|
||||
module ClassMethods
|
||||
# Attributes named in this macro are protected from mass-assignment
|
||||
# whenever attributes are sanitized before assignment. A role for the
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -115,7 +115,6 @@ module ActiveModel
|
|||
# @data[key]
|
||||
# end
|
||||
# end
|
||||
#
|
||||
alias :read_attribute_for_serialization :send
|
||||
|
||||
# Add associations specified via the <tt>:include</tt> option.
|
||||
|
|
|
@ -38,7 +38,6 @@ module ActiveModel
|
|||
# Note that <tt>ActiveModel::Validations</tt> automatically adds an +errors+ method
|
||||
# to your instances initialized with a new <tt>ActiveModel::Errors</tt> object, so
|
||||
# there is no need for you to do this manually.
|
||||
#
|
||||
module Validations
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
|
@ -222,7 +221,6 @@ module ActiveModel
|
|||
# @data[key]
|
||||
# end
|
||||
# end
|
||||
#
|
||||
alias :read_attribute_for_validation :send
|
||||
|
||||
protected
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -94,7 +94,6 @@ module ActiveModel #:nodoc:
|
|||
#
|
||||
# This setup method is only called when used with validation macros or the
|
||||
# class level <tt>validates_with</tt> method.
|
||||
#
|
||||
class Validator
|
||||
attr_reader :options
|
||||
|
||||
|
@ -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
|
||||
|
|
|
@ -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", {}, {}],
|
||||
|
|
|
@ -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:
|
||||
# <tt>composed_of :address</tt> adds <tt>address</tt> and <tt>address=(new_address)</tt> 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)
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -339,7 +339,6 @@ module ActiveRecord
|
|||
# t.remove_index
|
||||
# t.remove_timestamps
|
||||
# end
|
||||
#
|
||||
class Table
|
||||
def initialize(table_name, base)
|
||||
@table_name = table_name
|
||||
|
|
|
@ -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}"
|
||||
|
|
|
@ -59,7 +59,6 @@ module ActiveRecord
|
|||
# * <tt>:sslcert</tt> - Necessary to use MySQL with an SSL connection.
|
||||
# * <tt>:sslcapath</tt> - Necessary to use MySQL with an SSL connection.
|
||||
# * <tt>:sslcipher</tt> - Necessary to use MySQL with an SSL connection.
|
||||
#
|
||||
class MysqlAdapter < AbstractMysqlAdapter
|
||||
|
||||
class Column < AbstractMysqlAdapter::Column #:nodoc:
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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('|')
|
||||
|
|
|
@ -46,7 +46,6 @@ module ActiveRecord
|
|||
# class Person < ActiveRecord::Base
|
||||
# self.locking_column = :lock_person
|
||||
# end
|
||||
#
|
||||
module Optimistic
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
|
|
|
@ -7,7 +7,6 @@ module ActiveRecord
|
|||
# class Post
|
||||
# include ActiveRecord::Model
|
||||
# end
|
||||
#
|
||||
module Model
|
||||
module ClassMethods #:nodoc:
|
||||
include ActiveSupport::Callbacks::ClassMethods
|
||||
|
|
|
@ -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 <tt>ModelObserver.instance</tt> before. Observers are
|
||||
# singletons and that call instantiates and registers them.
|
||||
#
|
||||
class Observer < ActiveModel::Observer
|
||||
|
||||
protected
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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 <tt>:through</tt> source reflection names:
|
||||
#
|
||||
# [:singularized, :pluralized]
|
||||
#
|
||||
def source_reflection_names
|
||||
@source_reflection_names ||= (options[:source] ? [options[:source]] : [name.to_s.singularize, name]).collect { |n| n.to_sym }
|
||||
end
|
||||
|
|
|
@ -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}"
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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", {}, {}],
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 : {}
|
||||
|
|
|
@ -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", [])
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -136,7 +136,6 @@ class Array
|
|||
# <user-id>1</user-id>
|
||||
# </message>
|
||||
# </messages>
|
||||
#
|
||||
def to_xml(options = {})
|
||||
require 'active_support/builder' unless defined?(Builder)
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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" => <Person ...>, "chade-" => <Person ...>, ...}
|
||||
# people.index_by { |person| "#{person.first_name} #{person.last_name}" }
|
||||
# => { "Chade- Fowlersburg-e" => <Person ...>, "David Heinemeier Hansson" => <Person ...>, ...}
|
||||
#
|
||||
def index_by
|
||||
if block_given?
|
||||
Hash[map { |elem| [yield(elem), elem] }]
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -5,7 +5,6 @@ class Hash
|
|||
# Returns an <tt>ActiveSupport::HashWithIndifferentAccess</tt> out of its receiver:
|
||||
#
|
||||
# {:a => 1}.with_indifferent_access["a"] # => 1
|
||||
#
|
||||
def with_indifferent_access
|
||||
ActiveSupport::HashWithIndifferentAccess.new_from_hash_copying_default(self)
|
||||
end
|
||||
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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]
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -36,7 +36,6 @@ class Object
|
|||
#
|
||||
# <tt>with_options</tt> can also be nested since the call is forwarded to its receiver.
|
||||
# Each nesting level will merge inherited defaults in addition to their own.
|
||||
#
|
||||
def with_options(options)
|
||||
yield ActiveSupport::OptionMerger.new(self, options)
|
||||
end
|
||||
|
|
|
@ -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.
|
||||
#
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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] = [] }
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -36,7 +36,6 @@ module ActiveSupport
|
|||
# Options:
|
||||
# * <tt>:cipher</tt> - Cipher to use. Can be any cipher returned by <tt>OpenSSL::Cipher.ciphers</tt>. Default is 'aes-256-cbc'
|
||||
# * <tt>:serializer</tt> - Object serializer to use. Default is +Marshal+.
|
||||
#
|
||||
def initialize(secret, options = {})
|
||||
@secret = secret
|
||||
@cipher = options[:cipher] || 'aes-256-cbc'
|
||||
|
|
|
@ -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) }
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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] == "?"
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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'
|
||||
|
|
|
@ -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 = []
|
||||
|
|
|
@ -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?
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Reference in a new issue