activesupport 4.2.0 → 5.0.0.1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of activesupport might be problematic. Click here for more details.

Files changed (185) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +630 -220
  3. data/MIT-LICENSE +2 -2
  4. data/README.rdoc +2 -3
  5. data/lib/active_support/array_inquirer.rb +44 -0
  6. data/lib/active_support/backtrace_cleaner.rb +1 -1
  7. data/lib/active_support/benchmarkable.rb +1 -1
  8. data/lib/active_support/cache/file_store.rb +36 -22
  9. data/lib/active_support/cache/mem_cache_store.rb +63 -54
  10. data/lib/active_support/cache/memory_store.rb +16 -21
  11. data/lib/active_support/cache/null_store.rb +1 -4
  12. data/lib/active_support/cache/strategy/local_cache.rb +31 -20
  13. data/lib/active_support/cache.rb +73 -89
  14. data/lib/active_support/callbacks.rb +195 -155
  15. data/lib/active_support/concern.rb +2 -2
  16. data/lib/active_support/concurrency/latch.rb +7 -15
  17. data/lib/active_support/concurrency/share_lock.rb +186 -0
  18. data/lib/active_support/configurable.rb +1 -0
  19. data/lib/active_support/core_ext/array/access.rb +27 -1
  20. data/lib/active_support/core_ext/array/conversions.rb +6 -4
  21. data/lib/active_support/core_ext/array/grouping.rb +9 -18
  22. data/lib/active_support/core_ext/array/inquiry.rb +17 -0
  23. data/lib/active_support/core_ext/array/wrap.rb +5 -4
  24. data/lib/active_support/core_ext/array.rb +1 -0
  25. data/lib/active_support/core_ext/big_decimal/conversions.rb +8 -10
  26. data/lib/active_support/core_ext/class/attribute.rb +10 -9
  27. data/lib/active_support/core_ext/class/subclasses.rb +3 -4
  28. data/lib/active_support/core_ext/class.rb +0 -1
  29. data/lib/active_support/core_ext/date/blank.rb +12 -0
  30. data/lib/active_support/core_ext/date/calculations.rb +1 -1
  31. data/lib/active_support/core_ext/date/conversions.rb +13 -6
  32. data/lib/active_support/core_ext/date.rb +1 -1
  33. data/lib/active_support/core_ext/date_and_time/calculations.rb +109 -25
  34. data/lib/active_support/core_ext/date_and_time/compatibility.rb +18 -0
  35. data/lib/active_support/core_ext/date_and_time/zones.rb +3 -4
  36. data/lib/active_support/core_ext/date_time/blank.rb +12 -0
  37. data/lib/active_support/core_ext/date_time/calculations.rb +36 -10
  38. data/lib/active_support/core_ext/date_time/compatibility.rb +5 -0
  39. data/lib/active_support/core_ext/date_time/conversions.rb +2 -0
  40. data/lib/active_support/core_ext/date_time.rb +2 -1
  41. data/lib/active_support/core_ext/enumerable.rb +49 -5
  42. data/lib/active_support/core_ext/file/atomic.rb +30 -25
  43. data/lib/active_support/core_ext/hash/conversions.rb +23 -4
  44. data/lib/active_support/core_ext/hash/deep_merge.rb +1 -1
  45. data/lib/active_support/core_ext/hash/except.rb +9 -8
  46. data/lib/active_support/core_ext/hash/indifferent_access.rb +1 -1
  47. data/lib/active_support/core_ext/hash/keys.rb +23 -19
  48. data/lib/active_support/core_ext/hash/slice.rb +1 -1
  49. data/lib/active_support/core_ext/hash/transform_values.rb +11 -5
  50. data/lib/active_support/core_ext/integer/time.rb +1 -16
  51. data/lib/active_support/core_ext/kernel/concern.rb +2 -0
  52. data/lib/active_support/core_ext/kernel/debugger.rb +3 -10
  53. data/lib/active_support/core_ext/kernel/reporting.rb +2 -83
  54. data/lib/active_support/core_ext/kernel.rb +0 -1
  55. data/lib/active_support/core_ext/load_error.rb +4 -2
  56. data/lib/active_support/core_ext/marshal.rb +12 -11
  57. data/lib/active_support/core_ext/module/aliasing.rb +6 -1
  58. data/lib/active_support/core_ext/module/anonymous.rb +10 -1
  59. data/lib/active_support/core_ext/module/attr_internal.rb +2 -5
  60. data/lib/active_support/core_ext/module/attribute_accessors.rb +15 -15
  61. data/lib/active_support/core_ext/module/attribute_accessors_per_thread.rb +141 -0
  62. data/lib/active_support/core_ext/module/concerning.rb +4 -4
  63. data/lib/active_support/core_ext/module/delegation.rb +35 -25
  64. data/lib/active_support/core_ext/module/deprecation.rb +2 -2
  65. data/lib/active_support/core_ext/module/introspection.rb +4 -0
  66. data/lib/active_support/core_ext/module/method_transplanting.rb +3 -11
  67. data/lib/active_support/core_ext/module/qualified_const.rb +30 -12
  68. data/lib/active_support/core_ext/module/remove_method.rb +23 -0
  69. data/lib/active_support/core_ext/module.rb +1 -0
  70. data/lib/active_support/core_ext/name_error.rb +15 -2
  71. data/lib/active_support/core_ext/numeric/bytes.rb +20 -0
  72. data/lib/active_support/core_ext/numeric/conversions.rb +74 -64
  73. data/lib/active_support/core_ext/numeric/inquiry.rb +26 -0
  74. data/lib/active_support/core_ext/numeric/time.rb +24 -19
  75. data/lib/active_support/core_ext/numeric.rb +1 -0
  76. data/lib/active_support/core_ext/object/blank.rb +17 -5
  77. data/lib/active_support/core_ext/object/deep_dup.rb +10 -3
  78. data/lib/active_support/core_ext/object/duplicable.rb +8 -13
  79. data/lib/active_support/core_ext/object/inclusion.rb +2 -2
  80. data/lib/active_support/core_ext/object/instance_variables.rb +1 -1
  81. data/lib/active_support/core_ext/object/json.rb +15 -7
  82. data/lib/active_support/core_ext/object/to_query.rb +1 -1
  83. data/lib/active_support/core_ext/object/try.rb +68 -22
  84. data/lib/active_support/core_ext/object/with_options.rb +1 -1
  85. data/lib/active_support/core_ext/object.rb +0 -1
  86. data/lib/active_support/core_ext/range/conversions.rb +18 -6
  87. data/lib/active_support/core_ext/range/each.rb +16 -18
  88. data/lib/active_support/core_ext/range/include_range.rb +20 -20
  89. data/lib/active_support/core_ext/securerandom.rb +23 -0
  90. data/lib/active_support/core_ext/string/access.rb +1 -1
  91. data/lib/active_support/core_ext/string/behavior.rb +1 -1
  92. data/lib/active_support/core_ext/string/conversions.rb +4 -3
  93. data/lib/active_support/core_ext/string/filters.rb +5 -5
  94. data/lib/active_support/core_ext/string/inflections.rb +32 -5
  95. data/lib/active_support/core_ext/string/multibyte.rb +11 -7
  96. data/lib/active_support/core_ext/string/output_safety.rb +18 -16
  97. data/lib/active_support/core_ext/string/strip.rb +3 -6
  98. data/lib/active_support/core_ext/struct.rb +3 -6
  99. data/lib/active_support/core_ext/time/calculations.rb +36 -11
  100. data/lib/active_support/core_ext/time/compatibility.rb +5 -0
  101. data/lib/active_support/core_ext/time/conversions.rb +4 -2
  102. data/lib/active_support/core_ext/time/marshal.rb +2 -29
  103. data/lib/active_support/core_ext/time/zones.rb +36 -4
  104. data/lib/active_support/core_ext/time.rb +1 -1
  105. data/lib/active_support/core_ext/uri.rb +1 -3
  106. data/lib/active_support/core_ext.rb +2 -1
  107. data/lib/active_support/dependencies/interlock.rb +51 -0
  108. data/lib/active_support/dependencies.rb +87 -95
  109. data/lib/active_support/deprecation/behaviors.rb +16 -2
  110. data/lib/active_support/deprecation/method_wrappers.rb +42 -16
  111. data/lib/active_support/deprecation/proxy_wrappers.rb +47 -24
  112. data/lib/active_support/deprecation/reporting.rb +23 -5
  113. data/lib/active_support/deprecation.rb +1 -1
  114. data/lib/active_support/duration/iso8601_parser.rb +122 -0
  115. data/lib/active_support/duration/iso8601_serializer.rb +51 -0
  116. data/lib/active_support/duration.rb +55 -10
  117. data/lib/active_support/evented_file_update_checker.rb +194 -0
  118. data/lib/active_support/execution_wrapper.rb +117 -0
  119. data/lib/active_support/executor.rb +6 -0
  120. data/lib/active_support/file_update_checker.rb +23 -3
  121. data/lib/active_support/gem_version.rb +4 -4
  122. data/lib/active_support/hash_with_indifferent_access.rb +46 -13
  123. data/lib/active_support/i18n_railtie.rb +25 -4
  124. data/lib/active_support/inflector/inflections.rb +36 -5
  125. data/lib/active_support/inflector/methods.rb +97 -90
  126. data/lib/active_support/inflector/transliterate.rb +36 -21
  127. data/lib/active_support/json/decoding.rb +11 -10
  128. data/lib/active_support/json/encoding.rb +4 -49
  129. data/lib/active_support/key_generator.rb +7 -9
  130. data/lib/active_support/locale/en.yml +2 -0
  131. data/lib/active_support/log_subscriber/test_helper.rb +3 -3
  132. data/lib/active_support/log_subscriber.rb +1 -1
  133. data/lib/active_support/logger.rb +50 -1
  134. data/lib/active_support/logger_silence.rb +8 -4
  135. data/lib/active_support/logger_thread_safe_level.rb +31 -0
  136. data/lib/active_support/message_encryptor.rb +4 -4
  137. data/lib/active_support/message_verifier.rb +70 -8
  138. data/lib/active_support/multibyte/chars.rb +13 -4
  139. data/lib/active_support/multibyte/unicode.rb +44 -21
  140. data/lib/active_support/notifications/fanout.rb +6 -6
  141. data/lib/active_support/notifications/instrumenter.rb +20 -2
  142. data/lib/active_support/notifications.rb +2 -2
  143. data/lib/active_support/number_helper/number_to_currency_converter.rb +7 -9
  144. data/lib/active_support/number_helper/number_to_delimited_converter.rb +8 -3
  145. data/lib/active_support/number_helper/number_to_human_converter.rb +6 -4
  146. data/lib/active_support/number_helper/number_to_human_size_converter.rb +6 -2
  147. data/lib/active_support/number_helper/number_to_percentage_converter.rb +1 -1
  148. data/lib/active_support/number_helper/number_to_phone_converter.rb +11 -2
  149. data/lib/active_support/number_helper/number_to_rounded_converter.rb +30 -25
  150. data/lib/active_support/number_helper.rb +90 -67
  151. data/lib/active_support/ordered_hash.rb +1 -1
  152. data/lib/active_support/ordered_options.rb +15 -1
  153. data/lib/active_support/per_thread_registry.rb +8 -3
  154. data/lib/active_support/rails.rb +2 -2
  155. data/lib/active_support/railtie.rb +6 -1
  156. data/lib/active_support/reloader.rb +129 -0
  157. data/lib/active_support/rescuable.rb +93 -47
  158. data/lib/active_support/security_utils.rb +7 -0
  159. data/lib/active_support/string_inquirer.rb +1 -1
  160. data/lib/active_support/subscriber.rb +5 -10
  161. data/lib/active_support/tagged_logging.rb +3 -1
  162. data/lib/active_support/test_case.rb +15 -29
  163. data/lib/active_support/testing/assertions.rb +15 -13
  164. data/lib/active_support/testing/autorun.rb +8 -1
  165. data/lib/active_support/testing/deprecation.rb +9 -8
  166. data/lib/active_support/testing/file_fixtures.rb +34 -0
  167. data/lib/active_support/testing/isolation.rb +22 -8
  168. data/lib/active_support/testing/method_call_assertions.rb +41 -0
  169. data/lib/active_support/testing/stream.rb +42 -0
  170. data/lib/active_support/testing/time_helpers.rb +13 -10
  171. data/lib/active_support/time_with_zone.rb +135 -46
  172. data/lib/active_support/values/time_zone.rb +95 -47
  173. data/lib/active_support/values/unicode_tables.dat +0 -0
  174. data/lib/active_support/xml_mini/jdom.rb +7 -6
  175. data/lib/active_support/xml_mini/libxml.rb +2 -2
  176. data/lib/active_support/xml_mini/nokogiri.rb +2 -2
  177. data/lib/active_support/xml_mini/rexml.rb +7 -8
  178. data/lib/active_support/xml_mini.rb +22 -14
  179. data/lib/active_support.rb +20 -6
  180. metadata +33 -35
  181. data/lib/active_support/core_ext/big_decimal/yaml_conversions.rb +0 -14
  182. data/lib/active_support/core_ext/class/delegating_attributes.rb +0 -45
  183. data/lib/active_support/core_ext/date_time/zones.rb +0 -6
  184. data/lib/active_support/core_ext/object/itself.rb +0 -15
  185. data/lib/active_support/core_ext/thread.rb +0 -86
data/CHANGELOG.md CHANGED
@@ -1,388 +1,798 @@
1
- * The decorated `load` and `require` methods are now kept private.
1
+ ## Rails 5.0.0 (June 30, 2016) ##
2
2
 
3
- Fixes #17553.
3
+ * Support parsing JSON time in ISO8601 local time strings in
4
+ `ActiveSupport::JSON.decode` when `parse_json_times` is enabled.
5
+ Strings in the format of `YYYY-MM-DD hh:mm:ss` (without a `Z` at
6
+ the end) will be parsed in the local timezone (`Time.zone`). In
7
+ addition, date strings (`YYYY-MM-DD`) are now parsed into `Date`
8
+ objects.
4
9
 
5
- *Xavier Noria*
10
+ *Grzegorz Witek*
6
11
 
7
- * `String#remove` and `String#remove!` accept multiple arguments.
12
+ * `Date.to_s` doesn't produce too many spaces. For example, `to_s(:short)`
13
+ will now produce `01 Feb` instead of ` 1 Feb`.
8
14
 
9
- *Pavel Pravosud*
15
+ Fixes #25251.
10
16
 
11
- * `TimeWithZone#strftime` now delegates every directive to `Time#strftime` except for '%Z',
12
- it also now correctly handles escaped '%' characters placed just before time zone related directives.
17
+ *Sean Griffin*
13
18
 
14
- *Pablo Herrero*
19
+ * Rescuable: If a handler doesn't match the exception, check for handlers
20
+ matching the exception's cause.
15
21
 
16
- * Corrected `Inflector#underscore` handling of multiple successive acroynms.
22
+ *Jeremy Daer*
17
23
 
18
- *James Le Cuirot*
24
+ * `ActiveSupport::Duration` supports weeks and hours.
19
25
 
20
- * Delegation now works with ruby reserved words passed to `:to` option.
26
+ [1.hour.inspect, 1.hour.value, 1.hour.parts]
27
+ # => ["3600 seconds", 3600, [[:seconds, 3600]]] # Before
28
+ # => ["1 hour", 3600, [[:hours, 1]]] # After
21
29
 
22
- Fixes #16956.
30
+ [1.week.inspect, 1.week.value, 1.week.parts]
31
+ # => ["7 days", 604800, [[:days, 7]]] # Before
32
+ # => ["1 week", 604800, [[:weeks, 1]]] # After
23
33
 
24
- *Agis Anastasopoulos*
34
+ This brings us into closer conformance with ISO8601 and relieves some
35
+ astonishment about getting `1.hour.inspect # => 3600 seconds`.
25
36
 
26
- * Added method `#eql?` to `ActiveSupport::Duration`, in addition to `#==`.
37
+ Compatibility: The duration's `value` remains the same, so apps using
38
+ durations are oblivious to the new time periods. Apps, libraries, and
39
+ plugins that work with the internal `parts` hash will need to broaden
40
+ their time period handling to cover hours & weeks.
27
41
 
28
- Currently, the following returns `false`, contrary to expectation:
42
+ *Andrey Novikov*
29
43
 
30
- 1.minute.eql?(1.minute)
44
+ * Time zones: Ensure that the UTC offset reflects DST changes that occurred
45
+ since the app started. Removes UTC offset caching, reducing performance,
46
+ but this is still relatively quick and isn't in any hot paths.
31
47
 
32
- Adding method `#eql?` will make this behave like expected. Method `#eql?` is
33
- just a bit stricter than `#==`, as it checks whether the argument is also a duration. Their
34
- parts may be different though.
48
+ *Alexey Shein*
35
49
 
36
- 1.minute.eql?(60.seconds) # => true
37
- 1.minute.eql?(60) # => false
50
+ * Make `getlocal` and `getutc` always return instances of `Time` for
51
+ `ActiveSupport::TimeWithZone` and `DateTime`. This eliminates a possible
52
+ stack level too deep error in `to_time` where `ActiveSupport::TimeWithZone`
53
+ was wrapping a `DateTime` instance. As a consequence of this the internal
54
+ time value in `ActiveSupport::TimeWithZone` is now always an instance of
55
+ `Time` in the UTC timezone, whether that's as the UTC time directly or
56
+ a representation of the local time in the timezone. There should be no
57
+ consequences of this internal change and if there are it's a bug due to
58
+ leaky abstractions.
38
59
 
39
- *Joost Lubach*
60
+ *Andrew White*
40
61
 
41
- * `Time#change` can now change nanoseconds (`:nsec`) as a higher-precision
42
- alternative to microseconds (`:usec`).
62
+ * Add `DateTime#subsec` to return the fraction of a second as a `Rational`.
43
63
 
44
- *Agis Anastasooulos*
64
+ *Andrew White*
45
65
 
46
- * `MessageVerifier.new` raises an appropriate exception if the secret is `nil`.
47
- This prevents `MessageVerifier#generate` from raising a cryptic error later on.
66
+ * Add additional aliases for `DateTime#utc` to mirror the ones on
67
+ `ActiveSupport::TimeWithZone` and `Time`.
48
68
 
49
- *Kostiantyn Kahanskyi*
69
+ *Andrew White*
50
70
 
51
- * Introduced new configuration option `active_support.test_order` for
52
- specifying the order in which test cases are executed. This option currently defaults
53
- to `:sorted` but will be changed to `:random` in Rails 5.0.
71
+ * Add `DateTime#localtime` to return an instance of `Time` in the system's
72
+ local timezone. Also aliased to `getlocal`.
54
73
 
55
- *Akira Matsuda*, *Godfrey Chan*
74
+ *Andrew White*, *Yuichiro Kaneko*
56
75
 
57
- * Fixed a bug in `Inflector#underscore` where acroynms in nested constant names
58
- are incorrectly parsed as camelCase.
76
+ * Add `Time#sec_fraction` to return the fraction of a second as a `Rational`.
59
77
 
60
- Fixes #8015.
78
+ *Andrew White*
61
79
 
62
- *Fred Wu*, *Matthew Draper*
80
+ * Add `ActiveSupport.to_time_preserves_timezone` config option to control
81
+ how `to_time` handles timezones. In Ruby 2.4+ the behavior will change
82
+ from converting to the local system timezone, to preserving the timezone
83
+ of the receiver. This config option defaults to false so that apps made
84
+ with earlier versions of Rails are not affected when upgrading, e.g:
63
85
 
64
- * Make `Time#change` throw an exception if the `:usec` option is out of range and
65
- the time has an offset other than UTC or local.
86
+ >> ENV['TZ'] = 'US/Eastern'
66
87
 
67
- *Agis Anastasopoulos*
88
+ >> "2016-04-23T10:23:12.000Z".to_time
89
+ => "2016-04-23T06:23:12.000-04:00"
68
90
 
69
- * `Method` objects now report themselves as not `duplicable?`. This allows
70
- hashes and arrays containing `Method` objects to be `deep_dup`ed.
91
+ >> ActiveSupport.to_time_preserves_timezone = true
71
92
 
72
- *Peter Jaros*
93
+ >> "2016-04-23T10:23:12.000Z".to_time
94
+ => "2016-04-23T10:23:12.000Z"
73
95
 
74
- * `determine_constant_from_test_name` does no longer shadow `NameError`s
75
- which happens during constant autoloading.
96
+ Fixes #24617.
76
97
 
77
- Fixes #9933.
98
+ *Andrew White*
78
99
 
79
- *Guo Xiang Tan*
100
+ * `ActiveSupport::TimeZone.country_zones(country_code)` looks up the
101
+ country's time zones by its two-letter ISO3166 country code, e.g.
80
102
 
81
- * Added instance_eval version to Object#try and Object#try!, so you can do this:
103
+ >> ActiveSupport::TimeZone.country_zones(:jp).map(&:to_s)
104
+ => ["(GMT+09:00) Osaka"]
82
105
 
83
- person.try { name.first }
106
+ >> ActiveSupport::TimeZone.country_zones(:uy).map(&:to_s)
107
+ => ["(GMT-03:00) Montevideo"]
84
108
 
85
- instead of:
109
+ *Andrey Novikov*
86
110
 
87
- person.try { |person| person.name.first }
111
+ * `Array#sum` compat with Ruby 2.4's native method.
88
112
 
89
- *DHH*, *Ari Pollak*
113
+ Ruby 2.4 introduces `Array#sum`, but it only supports numeric elements,
114
+ breaking our `Enumerable#sum` which supports arbitrary `Object#+`.
115
+ To fix, override `Array#sum` with our compatible implementation.
90
116
 
91
- * Fix the `ActiveSupport::Duration#instance_of?` method to return the right
92
- value with the class itself since it was previously delegated to the
93
- internal value.
117
+ Native Ruby 2.4:
94
118
 
95
- *Robin Dupret*
119
+ %w[ a b ].sum
120
+ # => TypeError: String can't be coerced into Fixnum
96
121
 
97
- * Fix rounding errors with `#travel_to` by resetting the usec on any passed time to zero, so we only travel
98
- with per-second precision, not anything deeper than that.
122
+ With `Enumerable#sum` shim:
99
123
 
100
- *DHH*
124
+ %w[ a b ].sum
125
+ # => 'ab'
101
126
 
102
- * Fix DateTime comparison with `DateTime::Infinity` object.
127
+ We tried shimming the fast path and falling back to the compatible path
128
+ if it fails, but that ends up slower even in simple cases due to the cost
129
+ of exception handling. Our only choice is to override the native `Array#sum`
130
+ with our `Enumerable#sum`.
103
131
 
104
- *Rafael Mendonça França*
132
+ *Jeremy Daer*
133
+
134
+ * `ActiveSupport::Duration` supports ISO8601 formatting and parsing.
135
+
136
+ ActiveSupport::Duration.parse('P3Y6M4DT12H30M5S')
137
+ # => 3 years, 6 months, 4 days, 12 hours, 30 minutes, and 5 seconds
138
+
139
+ (3.years + 3.days).iso8601
140
+ # => "P3Y3D"
141
+
142
+ Inspired by Arnau Siches' [ISO8601 gem](https://github.com/arnau/ISO8601/)
143
+ and rewritten by Andrey Novikov with suggestions from Andrew White. Test
144
+ data from the ISO8601 gem redistributed under MIT license.
145
+
146
+ (Will be used to support the PostgreSQL interval data type.)
147
+
148
+ *Andrey Novikov*, *Arnau Siches*, *Andrew White*
149
+
150
+ * `Cache#fetch(key, force: true)` forces a cache miss, so it must be called
151
+ with a block to provide a new value to cache. Fetching with `force: true`
152
+ but without a block now raises ArgumentError.
153
+
154
+ cache.fetch('key', force: true) # => ArgumentError
155
+
156
+ *Santosh Wadghule*
157
+
158
+ * Fix behavior of JSON encoding for `Exception`.
159
+
160
+ *namusyaka*
161
+
162
+ * Make `number_to_phone` format number with regexp pattern.
163
+
164
+ number_to_phone(18812345678, pattern: /(\d{3})(\d{4})(\d{4})/)
165
+ # => 188-1234-5678
166
+
167
+ *Pan Gaoyong*
168
+
169
+ * Match `String#to_time`'s behaviour to that of ruby's implementation for edge cases.
170
+
171
+ `nil` is now returned instead of the current date if the string provided does
172
+ contain time information, but none that is used to build the `Time` object.
173
+
174
+ Fixes #22958.
175
+
176
+ *Siim Liiser*
177
+
178
+ * Rely on the native DateTime#<=> implementation to handle non-datetime like
179
+ objects instead of returning `nil` ourselves. This restores the ability
180
+ of `DateTime` instances to be compared with a `Numeric` that represents an
181
+ astronomical julian day number.
105
182
 
106
- * Added Object#itself which returns the object itself. Useful when dealing with a chaining scenario, like Active Record scopes:
183
+ Fixes #24228.
107
184
 
108
- Event.public_send(state.presence_in([ :trashed, :drafted ]) || :itself).order(:created_at)
185
+ *Andrew White*
186
+
187
+ * Add `String#upcase_first` method.
188
+
189
+ *Glauco Custódio*, *bogdanvlviv*
190
+
191
+ * Prevent `Marshal.load` from looping infinitely when trying to autoload a constant
192
+ which resolves to a different name.
193
+
194
+ *Olek Janiszewski*
195
+
196
+ * Deprecate `Module.local_constants`. Please use `Module.constants(false)` instead.
197
+
198
+ *Yuichiro Kaneko*
199
+
200
+ * Publish `ActiveSupport::Executor` and `ActiveSupport::Reloader` APIs to allow
201
+ components and libraries to manage, and participate in, the execution of
202
+ application code, and the application reloading process.
203
+
204
+ *Matthew Draper*
205
+
206
+ * Deprecate arguments on `assert_nothing_raised`.
207
+
208
+ `assert_nothing_raised` does not assert the arguments that have been passed
209
+ in (usually a specific exception class) since the method only yields the
210
+ block. So as not to confuse the users that the arguments have meaning, they
211
+ are being deprecated.
212
+
213
+ *Tara Scherner de la Fuente*
214
+
215
+ * Make `benchmark('something', silence: true)` actually work.
109
216
 
110
217
  *DHH*
111
218
 
112
- * `Object#with_options` executes block in merging option context when
113
- explicit receiver in not passed.
219
+ * Add `#on_weekday?` method to `Date`, `Time`, and `DateTime`.
114
220
 
115
- *Pavel Pravosud*
221
+ `#on_weekday?` returns `true` if the receiving date/time does not fall on a Saturday
222
+ or Sunday.
116
223
 
117
- * Fixed a compatibility issue with the `Oj` gem when cherry-picking the file
118
- `active_support/core_ext/object/json` without requiring `active_support/json`.
224
+ *Vipul A M*
119
225
 
120
- Fixes #16131.
226
+ * Add `Array#second_to_last` and `Array#third_to_last` methods.
121
227
 
122
- *Godfrey Chan*
228
+ *Brian Christian*
123
229
 
124
- * Make `Hash#with_indifferent_access` copy the default proc too.
230
+ * Fix regression in `Hash#dig` for HashWithIndifferentAccess.
125
231
 
126
- *arthurnn*, *Xanders*
232
+ *Jon Moss*
127
233
 
128
- * Add `String#truncate_words` to truncate a string by a number of words.
234
+ * Change `number_to_currency` behavior for checking negativity.
129
235
 
130
- *Mohamed Osama*
236
+ Used `to_f.negative` instead of using `to_f.phase` for checking negativity
237
+ of a number in number_to_currency helper.
238
+ This change works same for all cases except when number is "-0.0".
131
239
 
132
- * Deprecate `capture` and `quietly`.
240
+ -0.0.to_f.negative? => false
241
+ -0.0.to_f.phase? => 3.14
133
242
 
134
- These methods are not thread safe and may cause issues when used in threaded environments.
135
- To avoid problems we are deprecating them.
243
+ This change reverts changes from https://github.com/rails/rails/pull/6512.
244
+ But it should be acceptable as we could not find any currency which
245
+ supports negative zeros.
136
246
 
137
- *Tom Meier*
247
+ *Prathamesh Sonpatki*, *Rafael Mendonça França*
138
248
 
139
- * `DateTime#to_f` now preserves the fractional seconds instead of always
140
- rounding to `.0`.
249
+ * Match `HashWithIndifferentAccess#default`'s behaviour with `Hash#default`.
141
250
 
142
- Fixes #15994.
251
+ *David Cornu*
143
252
 
144
- *John Paul Ashenfelter*
253
+ * Adds `:exception_object` key to `ActiveSupport::Notifications::Instrumenter`
254
+ payload when an exception is raised.
145
255
 
146
- * Add `Hash#transform_values` to simplify a common pattern where the values of a
147
- hash must change, but the keys are left the same.
256
+ Adds new key/value pair to payload when an exception is raised:
257
+ e.g. `:exception_object => #<RuntimeError: FAIL>`.
148
258
 
149
- *Sean Griffin*
259
+ *Ryan T. Hosford*
150
260
 
151
- * Always instrument `ActiveSupport::Cache`.
261
+ * Support extended grapheme clusters and UAX 29.
152
262
 
153
- Since `ActiveSupport::Notifications` only instruments items when there
154
- are attached subscribers, we don't need to disable instrumentation.
263
+ *Adam Roben*
155
264
 
156
- *Peter Wagenet*
265
+ * Add petabyte and exabyte numeric conversion.
157
266
 
158
- * Make the `apply_inflections` method case-insensitive when checking
159
- whether a word is uncountable or not.
267
+ *Akshay Vishnoi*
160
268
 
161
- *Robin Dupret*
269
+ * Add thread_m/cattr_accessor/reader/writer suite of methods for declaring class and module variables that live per-thread.
270
+ This makes it easy to declare per-thread globals that are encapsulated. Note: This is a sharp edge. A wild proliferation
271
+ of globals is A Bad Thing. But like other sharp tools, when it's right, it's right.
162
272
 
163
- * Make Dependencies pass a name to NameError error.
273
+ Here's an example of a simple event tracking system where the object being tracked needs not pass a creator that it
274
+ doesn't need itself along:
164
275
 
165
- *arthurnn*
276
+ module Current
277
+ thread_mattr_accessor :account
278
+ thread_mattr_accessor :user
166
279
 
167
- * Fixed `ActiveSupport::Cache::FileStore` exploding with long paths.
280
+ def self.reset() self.account = self.user = nil end
281
+ end
168
282
 
169
- *Adam Panzer*, *Michael Grosser*
283
+ class ApplicationController < ActionController::Base
284
+ before_action :set_current
285
+ after_action { Current.reset }
170
286
 
171
- * Fixed `ActiveSupport::TimeWithZone#-` so precision is not unnecessarily lost
172
- when working with objects with a nanosecond component.
287
+ private
288
+ def set_current
289
+ Current.account = Account.find(params[:account_id])
290
+ Current.user = Current.account.users.find(params[:user_id])
291
+ end
292
+ end
173
293
 
174
- `ActiveSupport::TimeWithZone#-` should return the same result as if we were
175
- using `Time#-`:
294
+ class MessagesController < ApplicationController
295
+ def create
296
+ @message = Message.create!(message_params)
297
+ end
298
+ end
176
299
 
177
- Time.now.end_of_day - Time.now.beginning_of_day # => 86399.999999999
300
+ class Message < ApplicationRecord
301
+ has_many :events
302
+ after_create :track_created
178
303
 
179
- Before:
304
+ private
305
+ def track_created
306
+ events.create! origin: self, action: :create
307
+ end
308
+ end
180
309
 
181
- Time.zone.now.end_of_day.nsec # => 999999999
182
- Time.zone.now.end_of_day - Time.zone.now.beginning_of_day # => 86400.0
310
+ class Event < ApplicationRecord
311
+ belongs_to :creator, class_name: 'User'
312
+ before_validation { self.creator ||= Current.user }
313
+ end
183
314
 
184
- After:
315
+ *DHH*
316
+
317
+
318
+ * Deprecated `Module#qualified_const_` in favour of the builtin Module#const_
319
+ methods.
320
+
321
+ *Genadi Samokovarov*
322
+
323
+ * Deprecate passing string to define callback.
324
+
325
+ *Yuichiro Kaneko*
326
+
327
+ * `ActiveSupport::Cache::Store#namespaced_key`,
328
+ `ActiveSupport::Cache::MemCachedStore#escape_key`, and
329
+ `ActiveSupport::Cache::FileStore#key_file_path`
330
+ are deprecated and replaced with `normalize_key` that now calls `super`.
331
+
332
+ `ActiveSupport::Cache::LocaleCache#set_cache_value` is deprecated and replaced with `write_cache_value`.
333
+
334
+ *Michael Grosser*
335
+
336
+ * Implements an evented file watcher to asynchronously detect changes in the
337
+ application source code, routes, locales, etc.
338
+
339
+ This watcher is disabled by default, applications my enable it in the configuration:
340
+
341
+ # config/environments/development.rb
342
+ config.file_watcher = ActiveSupport::EventedFileUpdateChecker
343
+
344
+ This feature depends on the [listen](https://github.com/guard/listen) gem:
345
+
346
+ group :development do
347
+ gem 'listen', '~> 3.0.5'
348
+ end
349
+
350
+ *Puneet Agarwal* and *Xavier Noria*
351
+
352
+ * Added `Time.days_in_year` to return the number of days in the given year, or the
353
+ current year if no argument is provided.
354
+
355
+ *Jon Pascoe*
356
+
357
+ * Updated `parameterize` to preserve the case of a string, optionally.
185
358
 
186
- Time.zone.now.end_of_day - Time.zone.now.beginning_of_day
187
- # => 86399.999999999
359
+ Example:
360
+
361
+ parameterize("Donald E. Knuth", separator: '_') # => "donald_e_knuth"
362
+ parameterize("Donald E. Knuth", preserve_case: true) # => "Donald-E-Knuth"
363
+
364
+ *Swaathi Kakarla*
365
+
366
+ * `HashWithIndifferentAccess.new` respects the default value or proc on objects
367
+ that respond to `#to_hash`. `.new_from_hash_copying_default` simply invokes `.new`.
368
+ All calls to `.new_from_hash_copying_default` are replaced with `.new`.
188
369
 
189
370
  *Gordon Chan*
190
371
 
191
- * Fixed precision error in NumberHelper when using Rationals.
372
+ * Change Integer#year to return a Fixnum instead of a Float to improve
373
+ consistency.
374
+
375
+ Integer#years returned a Float while the rest of the accompanying methods
376
+ (days, weeks, months, etc.) return a Fixnum.
192
377
 
193
378
  Before:
194
379
 
195
- ActiveSupport::NumberHelper.number_to_rounded Rational(1000, 3), precision: 2
196
- # => "330.00"
380
+ 1.year # => 31557600.0
197
381
 
198
382
  After:
199
383
 
200
- ActiveSupport::NumberHelper.number_to_rounded Rational(1000, 3), precision: 2
201
- # => "333.33"
384
+ 1.year # => 31557600
202
385
 
203
- See #15379.
386
+ *Konstantinos Rousis*
204
387
 
205
- *Juanjo Bazán*
388
+ * Handle invalid UTF-8 strings when HTML escaping.
206
389
 
207
- * Removed deprecated `Numeric#ago` and friends
390
+ Use `ActiveSupport::Multibyte::Unicode.tidy_bytes` to handle invalid UTF-8
391
+ strings in `ERB::Util.unwrapped_html_escape` and `ERB::Util.html_escape_once`.
392
+ Prevents user-entered input passed from a querystring into a form field from
393
+ causing invalid byte sequence errors.
208
394
 
209
- Replacements:
395
+ *Grey Baker*
210
396
 
211
- 5.ago => 5.seconds.ago
212
- 5.until => 5.seconds.until
213
- 5.since => 5.seconds.since
214
- 5.from_now => 5.seconds.from_now
397
+ * Update `ActiveSupport::Multibyte::Chars#slice!` to return `nil` if the
398
+ arguments are out of bounds, to mirror the behavior of `String#slice!`
215
399
 
216
- See #12389 for the history and rationale behind this.
400
+ *Gourav Tiwari*
217
401
 
218
- *Godfrey Chan*
402
+ * Fix `number_to_human` so that 999999999 rounds to "1 Billion" instead of
403
+ "1000 Million".
404
+
405
+ *Max Jacobson*
406
+
407
+ * Fix `ActiveSupport::Deprecation#deprecate_methods` to report using the
408
+ current deprecator instance, where applicable.
409
+
410
+ *Brandon Dunne*
411
+
412
+ * `Cache#fetch` instrumentation marks whether it was a `:hit`.
413
+
414
+ *Robin Clowers*
415
+
416
+ * `assert_difference` and `assert_no_difference` now returns the result of the
417
+ yielded block.
418
+
419
+ Example:
420
+
421
+ post = assert_difference -> { Post.count }, 1 do
422
+ Post.create
423
+ end
424
+
425
+ *Lucas Mazza*
426
+
427
+ * Short-circuit `blank?` on date and time values since they are never blank.
428
+
429
+ Fixes #21657.
430
+
431
+ *Andrew White*
432
+
433
+ * Replaced deprecated `ThreadSafe::Cache` with its successor `Concurrent::Map` now that
434
+ the thread_safe gem has been merged into concurrent-ruby.
435
+
436
+ *Jerry D'Antonio*
437
+
438
+ * Updated Unicode version to 8.0.0
439
+
440
+ *Anshul Sharma*
441
+
442
+ * `number_to_currency` and `number_with_delimiter` now accept custom `delimiter_pattern` option
443
+ to handle placement of delimiter, to support currency formats like INR
219
444
 
220
- * DateTime `advance` now supports partial days.
445
+ Example:
446
+
447
+ number_to_currency(1230000, delimiter_pattern: /(\d+?)(?=(\d\d)+(\d)(?!\d))/, unit: '₹', format: "%u %n")
448
+ # => '₹ 12,30,000.00'
449
+
450
+ *Vipul A M*
451
+
452
+ * Deprecate `:prefix` option of `number_to_human_size` with no replacement.
453
+
454
+ *Jean Boussier*
455
+
456
+ * Fix `TimeWithZone#eql?` to properly handle `TimeWithZone` created from `DateTime`:
457
+ twz = DateTime.now.in_time_zone
458
+ twz.eql?(twz.dup) => true
459
+
460
+ Fixes #14178.
461
+
462
+ *Roque Pinel*
463
+
464
+ * ActiveSupport::HashWithIndifferentAccess `select` and `reject` will now return
465
+ enumerator if called without block.
466
+
467
+ Fixes #20095.
468
+
469
+ *Bernard Potocki*
470
+
471
+ * Removed `ActiveSupport::Concurrency::Latch`, superseded by `Concurrent::CountDownLatch`
472
+ from the concurrent-ruby gem.
473
+
474
+ *Jerry D'Antonio*
475
+
476
+ * Fix not calling `#default` on `HashWithIndifferentAccess#to_hash` when only
477
+ `default_proc` is set, which could raise.
478
+
479
+ *Simon Eskildsen*
480
+
481
+ * Fix setting `default_proc` on `HashWithIndifferentAccess#dup`.
482
+
483
+ *Simon Eskildsen*
484
+
485
+ * Fix a range of values for parameters of the Time#change.
486
+
487
+ *Nikolay Kondratyev*
488
+
489
+ * Add `Enumerable#pluck` to get the same values from arrays as from ActiveRecord
490
+ associations.
491
+
492
+ Fixes #20339.
493
+
494
+ *Kevin Deisz*
495
+
496
+ * Add a bang version to `ActiveSupport::OrderedOptions` get methods which will raise
497
+ an `KeyError` if the value is `.blank?`.
221
498
 
222
499
  Before:
223
500
 
224
- DateTime.now.advance(days: 1, hours: 12)
501
+ if (slack_url = Rails.application.secrets.slack_url).present?
502
+ # Do something worthwhile
503
+ else
504
+ # Raise as important secret password is not specified
505
+ end
225
506
 
226
507
  After:
227
508
 
228
- DateTime.now.advance(days: 1.5)
509
+ slack_url = Rails.application.secrets.slack_url!
510
+
511
+ *Aditya Sanghi*, *Gaurish Sharma*
512
+
513
+ * Remove deprecated `Class#superclass_delegating_accessor`.
514
+ Use `Class#class_attribute` instead.
515
+
516
+ *Akshay Vishnoi*
517
+
518
+ * Patch `Delegator` to work with `#try`.
519
+
520
+ Fixes #5790.
521
+
522
+ *Nate Smith*
523
+
524
+ * Add `Integer#positive?` and `Integer#negative?` query methods
525
+ in the vein of `Fixnum#zero?`.
526
+
527
+ This makes it nicer to do things like `bunch_of_numbers.select(&:positive?)`.
528
+
529
+ *DHH*
530
+
531
+ * Encoding `ActiveSupport::TimeWithZone` to YAML now preserves the timezone information.
532
+
533
+ Fixes #9183.
229
534
 
230
- Fixes #12005.
535
+ *Andrew White*
231
536
 
232
- *Shay Davidson*
537
+ * Added `ActiveSupport::TimeZone#strptime` to allow parsing times as if
538
+ from a given timezone.
233
539
 
234
- * `Hash#deep_transform_keys` and `Hash#deep_transform_keys!` now transform hashes
235
- in nested arrays. This change also applies to `Hash#deep_stringify_keys`,
236
- `Hash#deep_stringify_keys!`, `Hash#deep_symbolize_keys` and
237
- `Hash#deep_symbolize_keys!`.
540
+ *Paul A Jungwirth*
238
541
 
239
- *OZAWA Sakuro*
542
+ * `ActiveSupport::Callbacks#skip_callback` now raises an `ArgumentError` if
543
+ an unrecognized callback is removed.
240
544
 
241
- * Fixed confusing `DelegationError` in `Module#delegate`.
545
+ *Iain Beeston*
242
546
 
243
- See #15186.
547
+ * Added `ActiveSupport::ArrayInquirer` and `Array#inquiry`.
244
548
 
245
- *Vladimir Yarotsky*
549
+ Wrapping an array in an `ArrayInquirer` gives a friendlier way to check its
550
+ contents:
246
551
 
247
- * Fixed `ActiveSupport::Subscriber` so that no duplicate subscriber is created
248
- when a subscriber method is redefined.
552
+ variants = ActiveSupport::ArrayInquirer.new([:phone, :tablet])
249
553
 
250
- *Dennis Schön*
554
+ variants.phone? # => true
555
+ variants.tablet? # => true
556
+ variants.desktop? # => false
251
557
 
252
- * Remove deprecated string based terminators for `ActiveSupport::Callbacks`.
558
+ variants.any?(:phone, :tablet) # => true
559
+ variants.any?(:phone, :desktop) # => true
560
+ variants.any?(:desktop, :watch) # => false
253
561
 
254
- *Eileen M. Uchitelle*
562
+ `Array#inquiry` is a shortcut for wrapping the receiving array in an
563
+ `ArrayInquirer`.
255
564
 
256
- * Fixed an issue when using
257
- `ActiveSupport::NumberHelper::NumberToDelimitedConverter` to
258
- convert a value that is an `ActiveSupport::SafeBuffer` introduced
259
- in 2da9d67.
565
+ *George Claghorn*
260
566
 
261
- See #15064.
567
+ * Deprecate `alias_method_chain` in favour of `Module#prepend` introduced in
568
+ Ruby 2.0.
262
569
 
263
- *Mark J. Titorenko*
570
+ *Kir Shatrov*
264
571
 
265
- * `TimeZone#parse` defaults the day of the month to '1' if any other date
266
- components are specified. This is more consistent with the behavior of
267
- `Time#parse`.
572
+ * Added `#without` on `Enumerable` and `Array` to return a copy of an
573
+ enumerable without the specified elements.
268
574
 
269
- *Ulysse Carion*
575
+ *Todd Bealmear*
270
576
 
271
- * `humanize` strips leading underscores, if any.
577
+ * Fixed a problem where `String#truncate_words` would get stuck with a complex
578
+ string.
579
+
580
+ *Henrik Nygren*
581
+
582
+ * Fixed a roundtrip problem with `AS::SafeBuffer` where primitive-like strings
583
+ will be dumped as primitives:
272
584
 
273
585
  Before:
274
586
 
275
- '_id'.humanize # => ""
587
+ YAML.load ActiveSupport::SafeBuffer.new("Hello").to_yaml # => "Hello"
588
+ YAML.load ActiveSupport::SafeBuffer.new("true").to_yaml # => true
589
+ YAML.load ActiveSupport::SafeBuffer.new("false").to_yaml # => false
590
+ YAML.load ActiveSupport::SafeBuffer.new("1").to_yaml # => 1
591
+ YAML.load ActiveSupport::SafeBuffer.new("1.1").to_yaml # => 1.1
276
592
 
277
593
  After:
278
594
 
279
- '_id'.humanize # => "Id"
595
+ YAML.load ActiveSupport::SafeBuffer.new("Hello").to_yaml # => "Hello"
596
+ YAML.load ActiveSupport::SafeBuffer.new("true").to_yaml # => "true"
597
+ YAML.load ActiveSupport::SafeBuffer.new("false").to_yaml # => "false"
598
+ YAML.load ActiveSupport::SafeBuffer.new("1").to_yaml # => "1"
599
+ YAML.load ActiveSupport::SafeBuffer.new("1.1").to_yaml # => "1.1"
280
600
 
281
- *Xavier Noria*
601
+ *Godfrey Chan*
282
602
 
283
- * Fixed backward compatibility issues introduced in 326e652.
603
+ * Enable `number_to_percentage` to keep the number's precision by allowing
604
+ `:precision` to be `nil`.
284
605
 
285
- Empty Hash or Array should not be present in serialization result.
606
+ *Jack Xu*
286
607
 
287
- {a: []}.to_query # => ""
288
- {a: {}}.to_query # => ""
608
+ * `config_accessor` became a private method, as with Ruby's `attr_accessor`.
289
609
 
290
- For more info see #14948.
610
+ *Akira Matsuda*
291
611
 
292
- *Bogdan Gusiev*
612
+ * `AS::Testing::TimeHelpers#travel_to` now changes `DateTime.now` as well as
613
+ `Time.now` and `Date.today`.
293
614
 
294
- * Add `Digest::UUID::uuid_v3` and `Digest::UUID::uuid_v5` to support stable
295
- UUID fixtures on PostgreSQL.
615
+ *Yuki Nishijima*
296
616
 
297
- *Roderick van Domburg*
617
+ * Add `file_fixture` to `ActiveSupport::TestCase`.
618
+ It provides a simple mechanism to access sample files in your test cases.
298
619
 
299
- * Fixed `ActiveSupport::Duration#eql?` so that `1.second.eql?(1.second)` is
300
- true.
620
+ By default file fixtures are stored in `test/fixtures/files`. This can be
621
+ configured per test-case using the `file_fixture_path` class attribute.
301
622
 
302
- This fixes the current situation of:
623
+ *Yves Senn*
303
624
 
304
- 1.second.eql?(1.second) # => false
625
+ * Return value of yielded block in `File.atomic_write`.
305
626
 
306
- `eql?` also requires that the other object is an `ActiveSupport::Duration`.
307
- This requirement makes `ActiveSupport::Duration`'s behavior consistent with
308
- the behavior of Ruby's numeric types:
627
+ *Ian Ker-Seymer*
309
628
 
310
- 1.eql?(1.0) # => false
311
- 1.0.eql?(1) # => false
629
+ * Duplicate frozen array when assigning it to a `HashWithIndifferentAccess` so
630
+ that it doesn't raise a `RuntimeError` when calling `map!` on it in `convert_value`.
312
631
 
313
- 1.second.eql?(1) # => false (was true)
314
- 1.eql?(1.second) # => false
632
+ Fixes #18550.
315
633
 
316
- { 1 => "foo", 1.0 => "bar" }
317
- # => { 1 => "foo", 1.0 => "bar" }
634
+ *Aditya Kapoor*
318
635
 
319
- { 1 => "foo", 1.second => "bar" }
320
- # now => { 1 => "foo", 1.second => "bar" }
321
- # was => { 1 => "bar" }
636
+ * Add missing time zone definitions for Russian Federation and sync them
637
+ with `zone.tab` file from tzdata version 2014j (latest).
322
638
 
323
- And though the behavior of these hasn't changed, for reference:
639
+ *Andrey Novikov*
324
640
 
325
- 1 == 1.0 # => true
326
- 1.0 == 1 # => true
641
+ * Add `SecureRandom.base58` for generation of random base58 strings.
327
642
 
328
- 1 == 1.second # => true
329
- 1.second == 1 # => true
643
+ *Matthew Draper*, *Guillermo Iguaran*
330
644
 
331
- *Emily Dobervich*
645
+ * Add `#prev_day` and `#next_day` counterparts to `#yesterday` and
646
+ `#tomorrow` for `Date`, `Time`, and `DateTime`.
332
647
 
333
- * `ActiveSupport::SafeBuffer#prepend` acts like `String#prepend` and modifies
334
- instance in-place, returning self. `ActiveSupport::SafeBuffer#prepend!` is
335
- deprecated.
648
+ *George Claghorn*
336
649
 
337
- *Pavel Pravosud*
650
+ * Add `same_time` option to `#next_week` and `#prev_week` for `Date`, `Time`,
651
+ and `DateTime`.
338
652
 
339
- * `HashWithIndifferentAccess` better respects `#to_hash` on objects it
340
- receives. In particular, `.new`, `#update`, `#merge`, and `#replace` accept
341
- objects which respond to `#to_hash`, even if those objects are not hashes
342
- directly.
653
+ *George Claghorn*
343
654
 
344
- *Peter Jaros*
655
+ * Add `#on_weekend?`, `#next_weekday`, `#prev_weekday` methods to `Date`,
656
+ `Time`, and `DateTime`.
345
657
 
346
- * Deprecate `Class#superclass_delegating_accessor`, use `Class#class_attribute` instead.
658
+ `#on_weekend?` returns `true` if the receiving date/time falls on a Saturday
659
+ or Sunday.
347
660
 
348
- *Akshay Vishnoi*
661
+ `#next_weekday` returns a new date/time representing the next day that does
662
+ not fall on a Saturday or Sunday.
349
663
 
350
- * Ensure classes which `include Enumerable` get `#to_json` in addition to
351
- `#as_json`.
664
+ `#prev_weekday` returns a new date/time representing the previous day that
665
+ does not fall on a Saturday or Sunday.
352
666
 
353
- *Sammy Larbi*
667
+ *George Claghorn*
354
668
 
355
- * Change the signature of `fetch_multi` to return a hash rather than an
356
- array. This makes it consistent with the output of `read_multi`.
669
+ * Added ability to `TaggedLogging` to allow loggers to be instantiated multiple times
670
+ so that they don't share tags with each other.
357
671
 
358
- *Parker Selbert*
672
+ Rails.logger = Logger.new(STDOUT)
359
673
 
360
- * Introduce `Concern#class_methods` as a sleek alternative to clunky
361
- `module ClassMethods`. Add `Kernel#concern` to define at the toplevel
362
- without chunky `module Foo; extend ActiveSupport::Concern` boilerplate.
674
+ # Before
675
+ custom_logger = ActiveSupport::TaggedLogging.new(Rails.logger)
676
+ custom_logger.push_tags "custom_tag"
677
+ custom_logger.info "test" # => "[custom_tag] [custom_tag] test"
678
+ Rails.logger.info "test" # => "[custom_tag] [custom_tag] test"
363
679
 
364
- # app/models/concerns/authentication.rb
365
- concern :Authentication do
366
- included do
367
- after_create :generate_private_key
368
- end
680
+ # After
681
+ custom_logger = ActiveSupport::TaggedLogging.new(Logger.new(STDOUT))
682
+ custom_logger.push_tags "custom_tag"
683
+ custom_logger.info "test" # => "[custom_tag] test"
684
+ Rails.logger.info "test" # => "test"
685
+
686
+ *Alexander Staubo*
369
687
 
370
- class_methods do
371
- def authenticate(credentials)
372
- # ...
688
+ * Change the default test order from `:sorted` to `:random`.
689
+
690
+ *Rafael Mendonça França*
691
+
692
+ * Remove deprecated `ActiveSupport::JSON::Encoding::CircularReferenceError`.
693
+
694
+ *Rafael Mendonça França*
695
+
696
+ * Remove deprecated methods `ActiveSupport::JSON::Encoding.encode_big_decimal_as_string=`
697
+ and `ActiveSupport::JSON::Encoding.encode_big_decimal_as_string`.
698
+
699
+ *Rafael Mendonça França*
700
+
701
+ * Remove deprecated `ActiveSupport::SafeBuffer#prepend`.
702
+
703
+ *Rafael Mendonça França*
704
+
705
+ * Remove deprecated methods at `Kernel`.
706
+
707
+ `silence_stderr`, `silence_stream`, `capture` and `quietly`.
708
+
709
+ *Rafael Mendonça França*
710
+
711
+ * Remove deprecated `active_support/core_ext/big_decimal/yaml_conversions`
712
+ file.
713
+
714
+ *Rafael Mendonça França*
715
+
716
+ * Remove deprecated methods `ActiveSupport::Cache::Store.instrument` and
717
+ `ActiveSupport::Cache::Store.instrument=`.
718
+
719
+ *Rafael Mendonça França*
720
+
721
+ * Change the way in which callback chains can be halted.
722
+
723
+ The preferred method to halt a callback chain from now on is to explicitly
724
+ `throw(:abort)`.
725
+ In the past, callbacks could only be halted by explicitly providing a
726
+ terminator and by having a callback match the conditions of the terminator.
727
+
728
+ * Add `ActiveSupport.halt_callback_chains_on_return_false`
729
+
730
+ Setting `ActiveSupport.halt_callback_chains_on_return_false`
731
+ to `true` will let an app support the deprecated way of halting Active Record,
732
+ and Active Model callback chains by returning `false`.
733
+
734
+ Setting the value to `false` will tell the app to ignore any `false` value
735
+ returned by those callbacks, and only halt the chain upon `throw(:abort)`.
736
+
737
+ When the configuration option is missing, its value is `true`, so older apps
738
+ ported to Rails 5.0 will not break (but display a deprecation warning).
739
+ For new Rails 5.0 apps, its value is set to `false` in an initializer, so
740
+ these apps will support the new behavior by default.
741
+
742
+ *claudiob*, *Roque Pinel*
743
+
744
+ * Changes arguments and default value of CallbackChain's `:terminator` option
745
+
746
+ Chains of callbacks defined without an explicit `:terminator` option will
747
+ now be halted as soon as a `before_` callback throws `:abort`.
748
+
749
+ Chains of callbacks defined with a `:terminator` option will maintain their
750
+ existing behavior of halting as soon as a `before_` callback matches the
751
+ terminator's expectation.
752
+
753
+ *claudiob*
754
+
755
+ * Deprecate `MissingSourceFile` in favor of `LoadError`.
756
+
757
+ `MissingSourceFile` was just an alias to `LoadError` and was not being
758
+ raised inside the framework.
759
+
760
+ *Rafael Mendonça França*
761
+
762
+ * Remove `Object#itself` as it is implemented in Ruby 2.2.
763
+
764
+ *Cristian Bica*
765
+
766
+ * Add support for error dispatcher classes in `ActiveSupport::Rescuable`.
767
+ Now it acts closer to Ruby's rescue.
768
+
769
+ Example:
770
+
771
+ class BaseController < ApplicationController
772
+ module ErrorDispatcher
773
+ def self.===(other)
774
+ Exception === other && other.respond_to?(:status)
373
775
  end
374
776
  end
375
777
 
376
- def generate_private_key
377
- # ...
778
+ rescue_from ErrorDispatcher do |error|
779
+ render status: error.status, json: { error: error.to_s }
378
780
  end
379
781
  end
380
782
 
381
- # app/models/user.rb
382
- class User < ActiveRecord::Base
383
- include Authentication
384
- end
783
+ *Genadi Samokovarov*
784
+
785
+ * Add `#verified` and `#valid_message?` methods to `ActiveSupport::MessageVerifier`
786
+
787
+ Previously, the only way to decode a message with `ActiveSupport::MessageVerifier`
788
+ was to use `#verify`, which would raise an exception on invalid messages. Now
789
+ `#verified` can also be used, which returns `nil` on messages that cannot be
790
+ decoded.
791
+
792
+ Previously, there was no way to check if a message's format was valid without
793
+ attempting to decode it. `#valid_message?` is a boolean convenience method that
794
+ checks whether the message is valid without actually decoding it.
385
795
 
386
- *Jeremy Kemper*
796
+ *Logan Leger*
387
797
 
388
- Please check [4-1-stable](https://github.com/rails/rails/blob/4-1-stable/activesupport/CHANGELOG.md) for previous changes.
798
+ Please check [4-2-stable](https://github.com/rails/rails/blob/4-2-stable/activesupport/CHANGELOG.md) for previous changes.