aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport
Commit message (Collapse)AuthorAgeFilesLines
* Deprecate `HWIDA.new_from_hash_copying_default`Sean Griffin2015-10-292-1/+6
| | | | This method was already niche, and is now redundant with `.new`
* Merge pull request #16357 from gchan/hwia-respects-to-hash-defaultSean Griffin2015-10-294-8/+32
|\ | | | | | | | | `HashWithIndifferentAccess.new` respects the default value or proc on objects that respond to `#to_hash`
| * `HashWithIndifferentAccess.new` respects the default value or proc on ↵Gordon Chan2014-07-314-8/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | objects that respond to `#to_hash`. Builds on the work of #12550 where `.new` will convert the object (that respond to `#to_hash`) to a hash and add that hash's keys and values to itself. This change will also make `.new` respect the default value or proc of objects that respond to `#to_hash`. In other words, this `.new` behaves exactly like `.new_from_hash_copying_default`. `.new_from_hash_copying_default` now simply invokes `.new` and any references to `.new_from_hash_copying_default` are replaced with `.new`. Added tests confirm behavior.
* | Make `Module#redefine_method` to keep method visibilityyui-knk2015-10-262-1/+32
| | | | | | | | | | | | | | Before this commit `Module#redefine_method` always changes visibility of redefined method to `public`. This commit changes behavior of Module#redefine_method` to keep method visibility.
* | Tweaked wording used in some tests.Sebastian McKenzie2015-10-251-6/+6
| |
* | [ci skip] Add more code examples for `Module#anonymous?` docsyui-knk2015-10-231-2/+4
| | | | | | | | | | In later code examples, it is better to write how `Module#anonymous?` works.
* | Change Integer#year to return a Fixnum instead of a Float to improve consistencyKonstantinos Rousis2015-10-222-1/+17
| |
* | Add Module#remove_possible_singleton_methodAndrew White2015-10-213-4/+32
| | | | | | | | | | This is primarily to fix method redefinition warnings in class_attribute but may be of use in other places where we define singleton methods.
* | Merge pull request #19889 from cedrics/long-uri-encoded-keysSean Griffin2015-10-202-3/+9
|\ \ | | | | | | FileStore: Long cache keys may result in too long paths due to encoding
| * | when checking for too long cache keys used the uri encoded fname Cedric Sohrauer2015-04-242-3/+9
| | |
* | | Merge pull request #19992 from greysteil/handle-invalid-utf8-in-html-escapeSean Griffin2015-10-203-4/+19
|\ \ \ | | | | | | | | | | | | Handle invalid UTF-8 strings when HTML escaping
| * | | Handle invalid UTF-8 strings when HTML escapingGrey Baker2015-06-083-4/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Use `ActiveSupport::Multibyte::Unicode.tidy_bytes` to handle invalid UTF-8 strings in `ERB::Util.unwrapped_html_escape` and `ERB::Util.html_escape_once`. Prevents user-entered input passed from a querystring into a form field from causing invalid byte sequence errors.
* | | | Merge pull request #20038 from imanel/numeric_prependSean Griffin2015-10-202-33/+19
|\ \ \ \ | | | | | | | | | | Use Module.prepend instead of alias_method and unify behavior of all Numeric extensions
| * | | | Unify behavior of all Numeric extensions and use Module.prepend instead of ↵Bernard Potocki2015-05-282-33/+19
| | | | | | | | | | | | | | | | | | | | alias_method
* | | | | Update #20737 to address feedbackSean Griffin2015-10-203-2/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Given that this pull request affects a mutable value, we need to test for and document the affects on the receiver in this case. Additionally, this pull request was missing a CHANGELOG entry.
* | | | | Fixed slice! behavior: return nil for out-of-bound parametersGourav Tiwari2015-10-202-1/+6
| | | | |
* | | | | Merge pull request #20872 from maxjacobson/more-humane-roundingSean Griffin2015-10-203-2/+11
|\ \ \ \ \ | | | | | | | | | | | | | | | | | | Round some numbers more humanely
| * | | | | Update the changelog for #20872 to be a bit less confusingSean Griffin2015-10-201-2/+2
| | | | | |
| * | | | | Round some numbers more humanelyMax Jacobson2015-07-263-2/+11
| | | | | | | | | | | | | | | | | | | | | | | | Fix #20869
* | | | | | Merge pull request #21302 from theunraveler/delegate_reserved_argument_namesSean Griffin2015-10-202-5/+21
|\ \ \ \ \ \ | | | | | | | | | | | | | | ActiveSupport: Fixing issue when delegating to methods named "block", "args", or "arg"
| * | | | | | Fixing issue when delegating to methods named "block", "args", or "arg"Jake Bell2015-08-192-5/+21
| | | | | | |
* | | | | | | Merge pull request #21883 from tarzan/cache-key-too-preciseSean Griffin2015-10-202-0/+2
|\ \ \ \ \ \ \ | | | | | | | | | | | | | | | | Fix precision on cache_key
| * | | | | | | fixes #21815Maarten Jacobs2015-10-162-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The default timestamp used for AR is `updated_at` in nanoseconds! (:nsec) This causes issues on any machine that runs an OS that supports nanoseconds timestamps, i.e. not-OS X, where the cache_key of the record persisted in the database (milliseconds precision) is out-of-sync with the cache_key in the ruby VM. This commit adds: A test that shows the issue, it can be found in the separate file `cache_key_test.rb`, because - model couldn't be defined inline - transactional testing needed to be turned off to get it to pass the MySQL tests This seemed cleaner than putting it in an existing testcase file. It adds :usec as a dateformat that calculates datetime in microseconds It sets precision of cache_key to :usec instead of :nsec, as no db supports nsec precision on timestamps
* | | | | | | | Merge pull request #21858 from Gaurav2728/protected_method_nodocRafael Mendonça França2015-10-201-3/+3
|\ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | nodoc for active support protected method [CI skip]
| * | | | | | | | nodoc for active support protected method [CI skip]Gaurav Sharma2015-10-041-3/+3
| | | | | | | | |
* | | | | | | | | Remove outdated statement about bundled TZInfo.Phil Ross2015-10-181-6/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The bundled version of TZInfo referred to was removed from Active Support in version 3.0.
* | | | | | | | | Use "rake time:zones:all" instead of "rake -D time" [ci skip]Marat Galiev2015-10-171-1/+1
| | | | | | | | |
* | | | | | | | | Merge pull request #21953 from bdunne/fix_dep_warnMatthew Draper2015-10-175-20/+92
|\ \ \ \ \ \ \ \ \ | |_|/ / / / / / / |/| | | | | | | | | | | | | | | | | Fix deprecation warning messages on deprecate_methods
| * | | | | | | | Fix bug where custom deprecators are not used.Brandon Dunne2015-10-144-20/+100
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add tests for ActiveSupport::Deprecation.deprecate_methods Modify ActiveSupport::Testing::Deprecation to allow a custom deprecator Leverage ActiveSupport::Testing::Deprecation assert_deprecated Update documentation for ActiveSupport::Deprecation.deprecate_methods Use cases: Using the default deprecator => "removed from Rails X.Y" Passing a custom deprecator in the options hash => "removed from MyGem next-release" Deprecating methods directly from custom deprecator => "removed from MyGem next-release"
* | | | | | | | | drop array allocations when iterating over the hashAaron Patterson2015-10-151-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `each_with_object` allocates an array for each kv pair. Switching to the slightly more verbose but less allocatey `each_pair` eliminates array allocations. Eliminating this allocation returns AR objects to have constant array allocations regardless of the number of columns the object has. Here is test code: ```ruby require 'active_record' class Topic < ActiveRecord::Base end 20.times do |i| Process.waitpid fork { ActiveRecord::Base.establish_connection adapter: 'sqlite3', database: ':memory:' ActiveRecord::Base.connection.instance_eval do create_table(:topics) do |t| t.string :title, limit: 250 t.string :author_name t.string :author_email_address t.string :parent_title t.string :type t.string :group i.times do |j| t.string :"aaa#{j}" end t.timestamps null: true end end ObjectSpace::AllocationTracer.setup(%i{type}) Topic.create title: "aaron" # heat cache result = ObjectSpace::AllocationTracer.trace do 10.times do |i| Topic.create title: "aaron #{i}" end end puts "#{Topic.columns.length},#{(result.find { |k,v| k.first == :T_ARRAY }.last.first / 10)}" } end ``` Before this commit: ``` 9,166 10,167 11,168 12,169 13,170 14,171 15,172 16,173 17,174 18,175 19,176 20,177 21,178 22,179 23,180 24,181 25,182 26,183 27,184 28,185 ``` After: ``` 9,157 10,157 11,157 12,157 13,157 14,157 15,157 16,157 17,157 18,157 19,157 20,157 21,157 22,157 23,157 24,157 25,157 26,157 27,157 28,157 ``` Left side is the number of columns, right is the number of allocations
* | | | | | | | | make string allocation constant regardless of column countAaron Patterson2015-10-151-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | deep_dup'ing a hash will dup the keys as well as the values. Since string keys from the source hash will be frozen, and the dup'd objects are immediately dup'd and frozen on insert in to the hash, the end user will only ever see two frozen strings. Since the strings are immutable, this commit just cheats a little and reuses the immutable strings. Just to reiterate, before this commit, deep duping a hash that looks like this: `{ "foo" => "bar" }` will generate two new instances of "foo". One is created when `deep_dup` is called on "foo", and the other is created when the newly allocated "foo" string is inserted in to the hash. The user never sees the intermediate "foo", and both copies of "foo" that the user *can* access will be frozen, so in this case we just reuse the existing frozen key. The upshot is that after this change, string allocations on AR allocations become constant regardless of the number of columns the model has. ```ruby require 'active_record' class Topic < ActiveRecord::Base end 20.times do |i| Process.waitpid fork { ActiveRecord::Base.establish_connection adapter: 'sqlite3', database: ':memory:' ActiveRecord::Base.connection.instance_eval do create_table(:topics) do |t| t.string :title, limit: 250 t.string :author_name t.string :author_email_address t.string :parent_title t.string :type t.string :group i.times do |j| t.integer :"aaa#{j}" end t.timestamps null: true end end ObjectSpace::AllocationTracer.setup(%i{type}) Topic.create title: "aaron" # heat cache result = ObjectSpace::AllocationTracer.trace do 10.times do |i| Topic.create title: "aaron #{i}" end end puts "#{Topic.columns.length},#{(result.find { |k,v| k.first == :T_STRING }.last.first / 10)}" } end ``` If you run the above script before this commit, the output looks like this: ``` [aaron@TC rails (master)]$ be ruby -rallocation_tracer test.rb 9,105 10,107 11,109 12,111 13,113 14,115 15,117 16,119 17,121 18,123 19,125 20,127 21,129 22,131 23,133 24,135 25,137 26,139 27,141 28,143 ``` The left column is the number of methods, the right column is the number of string allocations. Running against this commit, the output is: ``` [aaron@TC rails (master)]$ be ruby -rallocation_tracer test.rb 9,87 10,87 11,87 12,87 13,87 14,87 15,87 16,87 17,87 18,87 19,87 20,87 21,87 22,87 23,87 24,87 25,87 26,87 27,87 28,87 ``` As you can see, there is now only a constant number of strings allocated, regardless of the number of columns the model has.
* | | | | | | | | Merge pull request #21946 from davidcelis/fix-time-zone-utc-predicateAndrew White2015-10-152-1/+16
|\ \ \ \ \ \ \ \ \ | |/ / / / / / / / |/| | | | | | | | Expand support for ActiveSupport::TimeWithZone#utc?
| * | | | | | | | Expand support for ActiveSupport::TimeWithZone#utc?David Celis2015-10-152-1/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, ActiveSupport::TimeWithZone#utc? simply runs a check to see if the linked ActiveSupport::TimeZone's name is "UTC". This will only return true for ActiveSupport::TimeZone["UTC"], but not for time zones such as "Etc/UTC", "Etc/Universal", or other time zones that are aliases for UTC. Interestingly enough, ActiveSupport::TimeWithZone#utc? is also aliased as #gmt? but will return false for the "GMT" timezone (along with other TZInfo aliases for GMT). Instead of running a simple check on the TimeZone name, we can rely on the underlying TZInfo::TimezonePeriod and TZInfo::TimezoneOffset which keep a record of of the offset's abbreviated name. The possibilities here for UTC time zones are `:UTC`, `:UCT`, and `:GMT`. Signed-off-by: David <me@davidcel.is>
* | | | | | | | | Only prepend a single module when defining deprecation wrappers.Charles Oliver Nutter2015-10-131-4/+4
|/ / / / / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | I could not find any reason why each method got its own prepended module here, and all tests appear to pass with my change.
* | | | | | | | Merge pull request #21631 from RobinClowers/fix-cache-instrumentationJeremy Daer2015-10-093-13/+43
|\ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | Fix cache fetch instrumentation
| * | | | | | | | Fix Cache#fetch instrumentationRobin Clowers2015-09-141-13/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Before this change, you couldn't tell if a read was a hit or not when you called fetch.
| * | | | | | | | Add test cases for Cache#fetch instrumentationRobin Clowers2015-09-141-0/+28
| | | | | | | | |
* | | | | | | | | Avoid leaking the first relation we call #first onMatthew Draper2015-10-091-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | With the previous implementation, the block passed to define_singleton_method, which will live forever as the method body, captures the parameters (args and block) in its enclosure. For the current_scope registry, that can include an AR::Relation.
* | | | | | | | | code gardening in transliterate.rbXavier Noria2015-10-071-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Saw this while doing a review of a patch: * Normalize case and punctuation across comments. * ascii -> ASCII * Since I was on it, some blank lines that visually add some clarity IMO.
* | | | | | | | | Merge pull request #21868 from tanmay3011/fix_time_class_documentationVijay Dev2015-10-051-3/+3
|\ \ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | [ci skip] Fix #seconds_since_midnight documentation output it will al…
| * | | | | | | | | [ci skip] Fix #seconds_since_midnight documentation output it will always ↵Tanmay Sinha2015-10-051-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | return floating pointnumber
* | | | | | | | | | Merge pull request #21866 from tanmay3011/fix_documentationSean Griffin2015-10-041-1/+1
|\ \ \ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | Fix Time.now format in documentation [ci skip]
| * | | | | | | | | | Fix Time.now format in documentationTanmay Sinha2015-10-041-1/+1
| |/ / / / / / / / /
* | | | | | | | | | Merge pull request #21863 from tanmay3011/use_applications_yearSean Griffin2015-10-041-1/+1
|\ \ \ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | Use #current instead of #now to prevent zone issues and use new ruby …
| * | | | | | | | | | Use Time#current instead of Time#now to prevent zone issue inorder to use ↵Tanmay Sinha2015-10-041-1/+1
| |/ / / / / / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | application's time zone
* | | | | | | | | | Merge branch 'master' of github.com:rails/docrailsVijay Dev2015-10-045-5/+5
|\ \ \ \ \ \ \ \ \ \ | |/ / / / / / / / / |/| | | | | | | | |
| * | | | | | | | | [ci skip] default_normalization_form accessing from UnicodeGaurav Sharma2015-09-291-1/+1
| | | | | | | | | |
| * | | | | | | | | Renamed ‘Return’ to ‘Returns’ [ci skip]Ronak Jangir2015-09-283-3/+3
| | | | | | | | | |
| * | | | | | | | | Documentation typoAkira Matsuda2015-09-201-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | [ci skip]
* | | | | | | | | | Wrong usage of 'a' in docs fixed [ci skip]Mehmet Emin İNAÇ2015-10-031-1/+1
| |_|/ / / / / / / |/| | | | | | | |