diff options
Diffstat (limited to 'activesupport/CHANGELOG.md')
-rw-r--r-- | activesupport/CHANGELOG.md | 595 |
1 files changed, 225 insertions, 370 deletions
diff --git a/activesupport/CHANGELOG.md b/activesupport/CHANGELOG.md index 2cb1e79365..b2b3cf4bd4 100644 --- a/activesupport/CHANGELOG.md +++ b/activesupport/CHANGELOG.md @@ -1,527 +1,382 @@ -* Maintain proleptic gregorian in Time#advance +* `String#remove` and `String#remove!` accept multiple arguments. - `Time#advance` uses `Time#to_date` and `Date#advance` to calculate a new date. - The `Date` object returned by `Time#to_date` is constructed with the assumption - that the `Time` object represents a proleptic gregorian date, but it is - configured to observe the default julian calendar reform date (2299161j) - for purposes of calculating month, date and year: + *Pavel Pravosud* - Time.new(1582, 10, 4).to_date.to_s # => "1582-09-24" - Time.new(1582, 10, 4).to_date.gregorian.to_s # => "1582-10-04" +* TimeWithZone#strftime now delegates every directive to Time#strftime except for '%Z', + it also now correctly handles escaped '%' characters placed just before time zone related directives. - This patch ensures that when the intermediate `Date` object is advanced - to yield a new `Date` object, that the `Time` object for return is constructed - with a proleptic gregorian month, date and year. + *Pablo Herrero* - *Riley Lynch* +* Corrected Inflector#underscore handling of multiple successive acroynms. -* `MemCacheStore` should only accept a `Dalli::Client`, or create one. + *James Le Cuirot* - *arthurnn* - -* Don't lazy load the `tzinfo` library as it causes problems on Windows. - - Fixes #13553. +* Delegation now works with ruby reserved words passed to `:to` option. - *Andrew White* + Fixes #16956. -* Use `remove_possible_method` instead of `remove_method` to avoid - a `NameError` to be thrown on FreeBSD with the `Date` object. + *Agis Anastasopoulos* - *Rafael Mendonça França*, *Robin Dupret* +* Added method `#eql?` to `ActiveSupport::Duration`, in addition to `#==`. -* `blank?` and `present?` commit to return singletons. + Currently, the following returns `false`, contrary to expectation: - *Xavier Noria*, *Pavel Pravosud* + 1.minute.eql?(1.minute) -* Fixed Float related error in NumberHelper with large precisions. + Adding method `#eql?` will make this behave like expected. Method `#eql?` is + just a bit stricter than `#==`, as it checks whether the argument is also a duration. Their + parts may be different though. - Before: - - ActiveSupport::NumberHelper.number_to_rounded '3.14159', precision: 50 - #=> "3.14158999999999988261834005243144929409027099609375" + 1.minute.eql?(60.seconds) # => true + 1.minute.eql?(60) # => false - After: + *Joost Lubach* - ActiveSupport::NumberHelper.number_to_rounded '3.14159', precision: 50 - #=> "3.14159000000000000000000000000000000000000000000000" +* `Time#change` can now change nanoseconds (`:nsec`) as a higher-precision + alternative to microseconds (`:usec`). - *Kenta Murata*, *Akira Matsuda* + *Agis Anastasooulos* -* Default the new `I18n.enforce_available_locales` config to `true`, meaning - `I18n` will make sure that all locales passed to it must be declared in the - `available_locales` list. +* `MessageVerifier.new` raises an appropriate exception if the secret is `nil`. + This prevents `MessageVerifier#generate` from raising a cryptic error later on. - To disable it add the following configuration to your application: + *Kostiantyn Kahanskyi* - config.i18n.enforce_available_locales = false +* Introduced new configuration option `active_support.test_order` for + specifying the order in which test cases are executed. This option currently defaults + to `:sorted` but will be changed to `:random` in Rails 5.0. - This also ensures I18n configuration is properly initialized taking the new - option into account, to avoid their deprecations while booting up the app. + *Akira Matsuda*, *Godfrey Chan* - *Carlos Antonio da Silva*, *Yves Senn* +* Fixed a bug in `Inflector#underscore` where acroynms in nested constant names + are incorrectly parsed as camelCase. -* Introduce Module#concerning: a natural, low-ceremony way to separate - responsibilities within a class. + Fixes #8015. - Imported from https://github.com/37signals/concerning#readme + *Fred Wu*, *Matthew Draper* - class Todo < ActiveRecord::Base - concerning :EventTracking do - included do - has_many :events - end +* Make `Time#change` throw an exception if the `:usec` option is out of range and + the time has an offset other than UTC or local. - def latest_event - ... - end + *Agis Anastasopoulos* - private - def some_internal_method - ... - end - end +* `Method` objects now report themselves as not `duplicable?`. This allows + hashes and arrays containing `Method` objects to be `deep_dup`ed. - concerning :Trashable do - def trashed? - ... - end + *Peter Jaros* - def latest_event - super some_option: true - end - end - end +* `determine_constant_from_test_name` does no longer shadow `NameError`s + which happens during constant autoloading. - is equivalent to defining these modules inline, extending them into - concerns, then mixing them in to the class. + Fixes #9933. - Inline concerns tame "junk drawer" classes that intersperse many unrelated - class-level declarations, public instance methods, and private - implementation. Coalesce related bits and give them definition. - These are a stepping stone toward future growth & refactoring. + *Guo Xiang Tan* - When to move on from an inline concern: - * Encapsulating state? Extract collaborator object. - * Encompassing more public behavior or implementation? Move to separate file. - * Sharing behavior among classes? Move to separate file. +* Added instance_eval version to Object#try and Object#try!, so you can do this: - *Jeremy Kemper* + person.try { name.first } -* Fix file descriptor being leaked on each call to `Kernel.silence_stream`. + instead of: - *Mario Visic* + person.try { |person| person.name.first } -* Added `Date#all_week/month/quarter/year` for generating date ranges. + *DHH*, *Ari Pollak* - *Dmitriy Meremyanin* +* Fix the `ActiveSupport::Duration#instance_of?` method to return the right + value with the class itself since it was previously delegated to the + internal value. -* Add `Time.zone.yesterday` and `Time.zone.tomorrow`. These follow the - behavior of Ruby's `Date.yesterday` and `Date.tomorrow` but return localized - versions, similar to how `Time.zone.today` has returned a localized version - of `Date.today`. + *Robin Dupret* - *Colin Bartlett* +* Fix rounding errors with `#travel_to` by resetting the usec on any passed time to zero, so we only travel + with per-second precision, not anything deeper than that. -* Show valid keys when `assert_valid_keys` raises an exception, and show the - wrong value as it was entered. + *DHH* - *Gonzalo Rodríguez-Baltanás Díaz* +* Fix DateTime comparison with `DateTime::Infinity` object. -* Both `cattr_*` and `mattr_*` method definitions now live in `active_support/core_ext/module/attribute_accessors`. + *Rafael Mendonça França* - Requires to `active_support/core_ext/class/attribute_accessors` are - deprecated and will be removed in Ruby on Rails 4.2. +* Added Object#itself which returns the object itself. Useful when dealing with a chaining scenario, like Active Record scopes: - *Genadi Samokovarov* + Event.public_send(state.presence_in([ :trashed, :drafted ]) || :itself).order(:created_at) -* Deprecated `Numeric#{ago,until,since,from_now}`, the user is expected to explicitly - convert the value into an AS::Duration, i.e. `5.ago` => `5.seconds.ago` + *DHH* - This will help to catch subtle bugs like: +* `Object#with_options` executes block in merging option context when + explicit receiver in not passed. - def recent?(days = 3) - self.created_at >= days.ago - end + *Pavel Pravosud* - The above code would check if the model is created within the last 3 **seconds**. +* Fixed a compatibility issue with the `Oj` gem when cherry-picking the file + `active_support/core_ext/object/json` without requiring `active_support/json`. - In the future, `Numeric#{ago,until,since,from_now}` should be removed completely, - or throw some sort of errors to indicate there are no implicit conversion from - Numeric to AS::Duration. + Fixes #16131. *Godfrey Chan* -* Requires JSON gem version 1.7.7 or above due to a security issue in older versions. +* Make `Hash#with_indifferent_access` copy the default proc too. - *Godfrey Chan* + *arthurnn*, *Xanders* -* Removed the old pure-Ruby JSON encoder and switched to a new encoder based on the built-in JSON - gem. +* Add `String#truncate_words` to truncate a string by a number of words. - Support for encoding `BigDecimal` as a JSON number, as well as defining custom `encode_json` - methods to control the JSON output has been **removed from core**. The new encoder will always - encode BigDecimals as `String`s and ignore any custom `encode_json` methods. + *Mohamed Osama* - The old encoder has been extracted into the `activesupport-json_encoder` gem. Installing that - gem will bring back the ability to encode `BigDecimal`s as numbers as well as `encode_json` - support. +* Deprecate `capture` and `quietly`. - Setting the related configuration `ActiveSupport.encode_big_decimal_as_string` without the - `activesupport-json_encoder` gem installed will raise an error. + These methods are not thread safe and may cause issues when used in threaded environments. + To avoid problems we are deprecating them. - *Godfrey Chan* + *Tom Meier* -* Add `ActiveSupport::Testing::TimeHelpers#travel` and `#travel_to`. These methods change current - time to the given time or time difference by stubbing `Time.now` and `Date.today` to return the - time or date after the difference calculation, or the time or date that got passed into the - method respectively. +* `DateTime#to_f` now preserves the fractional seconds instead of always + rounding to `.0`. - Example for `#travel`: + Fixes #15994. - Time.now # => 2013-11-09 15:34:49 -05:00 - travel 1.day - Time.now # => 2013-11-10 15:34:49 -05:00 - Date.today # => Sun, 10 Nov 2013 + *John Paul Ashenfelter* - Example for `#travel_to`: +* Add `Hash#transform_values` to simplify a common pattern where the values of a + hash must change, but the keys are left the same. - Time.now # => 2013-11-09 15:34:49 -05:00 - travel_to Time.new(2004, 11, 24, 01, 04, 44) - Time.now # => 2004-11-24 01:04:44 -05:00 - Date.today # => Wed, 24 Nov 2004 + *Sean Griffin* - Both of these methods also accept a block, which will return the current time back to its - original state at the end of the block: +* Always instrument `ActiveSupport::Cache`. - Time.now # => 2013-11-09 15:34:49 -05:00 + Since `ActiveSupport::Notifications` only instruments items when there + are attached subscribers, we don't need to disable instrumentation. - travel 1.day do - User.create.created_at # => Sun, 10 Nov 2013 15:34:49 EST -05:00 - end + *Peter Wagenet* - travel_to Time.new(2004, 11, 24, 01, 04, 44) do - User.create.created_at # => Wed, 24 Nov 2004 01:04:44 EST -05:00 - end +* Make the `apply_inflections` method case-insensitive when checking + whether a word is uncountable or not. - Time.now # => 2013-11-09 15:34:49 -05:00 + *Robin Dupret* - This module is included in `ActiveSupport::TestCase` automatically. +* Make Dependencies pass a name to NameError error. - *Prem Sichanugrist*, *DHH* + *arthurnn* -* Unify `cattr_*` interface: allow to pass a block to `cattr_reader`. +* Fixed `ActiveSupport::Cache::FileStore` exploding with long paths. - Example: + *Adam Panzer / Michael Grosser* - class A - cattr_reader(:defr) { 'default_reader_value' } - end - A.defr # => 'default_reader_value' +* Fixed `ActiveSupport::TimeWithZone#-` so precision is not unnecessarily lost + when working with objects with a nanosecond component. - *Alexey Chernenkov* + `ActiveSupport::TimeWithZone#-` should return the same result as if we were + using `Time#-`: -* Improved compatibility with the stdlib JSON gem. + Time.now.end_of_day - Time.now.beginning_of_day # => 86399.999999999 - Previously, calling `::JSON.{generate,dump}` sometimes causes unexpected - failures such as intridea/multi_json#86. + Before: - `::JSON.{generate,dump}` now bypasses the ActiveSupport JSON encoder - completely and yields the same result with or without ActiveSupport. This - means that it will **not** call `as_json` and will ignore any options that - the JSON gem does not natively understand. To invoke ActiveSupport's JSON - encoder instead, use `obj.to_json(options)` or - `ActiveSupport::JSON.encode(obj, options)`. + Time.zone.now.end_of_day.nsec # => 999999999 + Time.zone.now.end_of_day - Time.zone.now.beginning_of_day # => 86400.0 - *Godfrey Chan* + After: -* Fix Active Support `Time#to_json` and `DateTime#to_json` to return 3 decimal - places worth of fractional seconds, similar to `TimeWithZone`. + Time.zone.now.end_of_day - Time.zone.now.beginning_of_day + # => 86399.999999999 - *Ryan Glover* + *Gordon Chan* -* Removed circular reference protection in JSON encoder, deprecated - `ActiveSupport::JSON::Encoding::CircularReferenceError`. +* Fixed precision error in NumberHelper when using Rationals. - *Godfrey Chan*, *Sergio Campamá* + Before: -* Add `capitalize` option to `Inflector.humanize`, so strings can be humanized without being capitalized: + ActiveSupport::NumberHelper.number_to_rounded Rational(1000, 3), precision: 2 + # => "330.00" - 'employee_salary'.humanize # => "Employee salary" - 'employee_salary'.humanize(capitalize: false) # => "employee salary" + After: - *claudiob* + ActiveSupport::NumberHelper.number_to_rounded Rational(1000, 3), precision: 2 + # => "333.33" -* Fixed `Object#as_json` and `Struct#as_json` not working properly with options. They now take - the same options as `Hash#as_json`: + See #15379. - struct = Struct.new(:foo, :bar).new - struct.foo = "hello" - struct.bar = "world" - json = struct.as_json(only: [:foo]) # => {foo: "hello"} + *Juanjo Bazán* - *Sergio Campamá*, *Godfrey Chan* +* Removed deprecated `Numeric#ago` and friends -* Added `Numeric#in_milliseconds`, like `1.hour.in_milliseconds`, so we can feed them to JavaScript functions like `getTime()`. + Replacements: - *DHH* + 5.ago => 5.seconds.ago + 5.until => 5.seconds.until + 5.since => 5.seconds.since + 5.from_now => 5.seconds.from_now -* Calling `ActiveSupport::JSON.decode` with unsupported options now raises an error. + See #12389 for the history and rationale behind this. *Godfrey Chan* -* Support `:unless_exist` in `FileStore`. +* DateTime `advance` now supports partial days. - *Michael Grosser* + Before: -* Fix `slice!` deleting the default value of the hash. + DateTime.now.advance(days: 1, hours: 12) - *Antonio Santos* + After: -* `require_dependency` accepts objects that respond to `to_path`, in - particular `Pathname` instances. + DateTime.now.advance(days: 1.5) - *Benjamin Fleischer* + Fixes #12005. -* Disable the ability to iterate over Range of AS::TimeWithZone - due to significant performance issues. + *Shay Davidson* - *Bogdan Gusiev* +* `Hash#deep_transform_keys` and `Hash#deep_transform_keys!` now transform hashes + in nested arrays. This change also applies to `Hash#deep_stringify_keys`, + `Hash#deep_stringify_keys!`, `Hash#deep_symbolize_keys` and + `Hash#deep_symbolize_keys!`. -* Allow attaching event subscribers to ActiveSupport::Notifications namespaces - before they're defined. Essentially, this means instead of this: + *OZAWA Sakuro* - class JokeSubscriber < ActiveSupport::Subscriber - def sql(event) - puts "A rabbi and a priest walk into a bar..." - end +* Fixed confusing `DelegationError` in `Module#delegate`. - # This call needs to happen *after* defining the methods. - attach_to "active_record" - end + See #15186. - You can do this: + *Vladimir Yarotsky* - class JokeSubscriber < ActiveSupport::Subscriber - # This is much easier to read! - attach_to "active_record" +* Fixed `ActiveSupport::Subscriber` so that no duplicate subscriber is created + when a subscriber method is redefined. - def sql(event) - puts "A rabbi and a priest walk into a bar..." - end - end + *Dennis Schön* - This should make it easier to read and understand these subscribers. +* Remove deprecated string based terminators for `ActiveSupport::Callbacks`. - *Daniel Schierbeck* + *Eileen M. Uchitelle* -* Add `Date#middle_of_day`, `DateTime#middle_of_day` and `Time#middle_of_day` methods. +* Fixed an issue when using + `ActiveSupport::NumberHelper::NumberToDelimitedConverter` to + convert a value that is an `ActiveSupport::SafeBuffer` introduced + in 2da9d67. - Also added `midday`, `noon`, `at_midday`, `at_noon` and `at_middle_of_day` as aliases. + See #15064. - *Anatoli Makarevich* - -* Fix ActiveSupport::Cache::FileStore#cleanup to no longer rely on missing each_key method. - - *Murray Steele* - -* Ensure that autoloaded constants in all-caps nestings are marked as - autoloaded. + *Mark J. Titorenko* - *Simon Coffey* +* `TimeZone#parse` defaults the day of the month to '1' if any other date + components are specified. This is more consistent with the behavior of + `Time#parse`. -* Add `String#remove(pattern)` as a short-hand for the common pattern of - `String#gsub(pattern, '')`. + *Ulysse Carion* - *DHH* +* `humanize` strips leading underscores, if any. -* Adds a new deprecation behaviour that raises an exception. Throwing this - line into +config/environments/development.rb+ + Before: - ActiveSupport::Deprecation.behavior = :raise + '_id'.humanize # => "" - will cause the application to raise an +ActiveSupport::DeprecationException+ - on deprecations. + After: - Use this for aggressive deprecation cleanups. + '_id'.humanize # => "Id" *Xavier Noria* -* Remove 'cow' => 'kine' irregular inflection from default inflections. - - *Andrew White* - -* Add `DateTime#to_s(:iso8601)` and `Date#to_s(:iso8601)` for consistency. +* Fixed backward compatibility issues introduced in 326e652. - *Andrew White* + Empty Hash or Array should not be present in serialization result. -* Add `Time#to_s(:iso8601)` for easy conversion of times to the iso8601 format for easy Javascript date parsing. - - *DHH* + {a: []}.to_query # => "" + {a: {}}.to_query # => "" -* Improve `ActiveSupport::Cache::MemoryStore` cache size calculation. - The memory used by a key/entry pair is calculated via `#cached_size`: + For more info see #14948. - def cached_size(key, entry) - key.to_s.bytesize + entry.size + PER_ENTRY_OVERHEAD - end - - The value of `PER_ENTRY_OVERHEAD` is 240 bytes based on an [empirical - estimation](https://gist.github.com/ssimeonov/6047200) for 64-bit MRI on - 1.9.3 and 2.0. - - Fixes #11512. - - *Simeon Simeonov* - -* Only raise `Module::DelegationError` if it's the source of the exception. - - Fixes #10559. - - *Andrew White* - -* Make `Time.at_with_coercion` retain the second fraction and return local time. - - Fixes #11350. - - *Neer Friedman*, *Andrew White* - -* Make `HashWithIndifferentAccess#select` always return the hash, even when - `Hash#select!` returns `nil`, to allow further chaining. - - *Marc Schütz* - -* Remove deprecated `String#encoding_aware?` core extensions (`core_ext/string/encoding`). - - *Arun Agrawal* - -* Remove deprecated `Module#local_constant_names` in favor of `Module#local_constants`. - - *Arun Agrawal* - -* Remove deprecated `DateTime.local_offset` in favor of `DateTime.civil_from_format`. - - *Arun Agrawal* - -* Remove deprecated `Logger` core extensions (`core_ext/logger.rb`). - - *Carlos Antonio da Silva* - -* Remove deprecated `Time#time_with_datetime_fallback`, `Time#utc_time` - and `Time#local_time` in favor of `Time#utc` and `Time#local`. - - *Vipul A M* - -* Remove deprecated `Hash#diff` with no replacement. - - If you're using it to compare hashes for the purpose of testing, please use - MiniTest's `assert_equal` instead. - - *Carlos Antonio da Silva* - -* Remove deprecated `Date#to_time_in_current_zone` in favor of `Date#in_time_zone`. - - *Vipul A M* - -* Remove deprecated `Proc#bind` with no replacement. - - *Carlos Antonio da Silva* - -* Remove deprecated `Array#uniq_by` and `Array#uniq_by!`, use native - `Array#uniq` and `Array#uniq!` instead. - - *Carlos Antonio da Silva* - -* Remove deprecated `ActiveSupport::BasicObject`, use `ActiveSupport::ProxyObject` instead. - - *Carlos Antonio da Silva* - -* Remove deprecated `BufferedLogger`, use `ActiveSupport::Logger` instead. - - *Yves Senn* - -* Remove deprecated `assert_present` and `assert_blank` methods, use `assert - object.blank?` and `assert object.present?` instead. - - *Yves Senn* - -* Fix return value from `BacktraceCleaner#noise` when the cleaner is configured - with multiple silencers. + *Bogdan Gusiev* - Fixes #11030. +* Add `Digest::UUID::uuid_v3` and `Digest::UUID::uuid_v5` to support stable + UUID fixtures on PostgreSQL. - *Mark J. Titorenko* + *Roderick van Domburg* -* `HashWithIndifferentAccess#select` now returns a `HashWithIndifferentAccess` - instance instead of a `Hash` instance. +* Fixed `ActiveSupport::Duration#eql?` so that `1.second.eql?(1.second)` is + true. - Fixes #10723. + This fixes the current situation of: - *Albert Llop* + 1.second.eql?(1.second) # => false -* Add `DateTime#usec` and `DateTime#nsec` so that `ActiveSupport::TimeWithZone` keeps - sub-second resolution when wrapping a `DateTime` value. + `eql?` also requires that the other object is an `ActiveSupport::Duration`. + This requirement makes `ActiveSupport::Duration`'s behavior consistent with + the behavior of Ruby's numeric types: - Fixes #10855. + 1.eql?(1.0) # => false + 1.0.eql?(1) # => false - *Andrew White* + 1.second.eql?(1) # => false (was true) + 1.eql?(1.second) # => false -* Fix `ActiveSupport::Dependencies::Loadable#load_dependency` calling - `#blame_file!` on Exceptions that do not have the Blamable mixin + { 1 => "foo", 1.0 => "bar" } + # => { 1 => "foo", 1.0 => "bar" } - *Andrew Kreiling* + { 1 => "foo", 1.second => "bar" } + # now => { 1 => "foo", 1.second => "bar" } + # was => { 1 => "bar" } -* Override `Time.at` to support the passing of Time-like values when called with a single argument. + And though the behavior of these hasn't changed, for reference: - *Andrew White* + 1 == 1.0 # => true + 1.0 == 1 # => true -* Prevent side effects to hashes inside arrays when - `Hash#with_indifferent_access` is called. + 1 == 1.second # => true + 1.second == 1 # => true - Fixes #10526. + *Emily Dobervich* - *Yves Senn* +* `ActiveSupport::SafeBuffer#prepend` acts like `String#prepend` and modifies + instance in-place, returning self. `ActiveSupport::SafeBuffer#prepend!` is + deprecated. -* Removed deprecated `ActiveSupport::JSON::Variable` with no replacement. + *Pavel Pravosud* - *Toshinori Kajihara* +* `HashWithIndifferentAccess` better respects `#to_hash` on objects it + receives. In particular, `.new`, `#update`, `#merge`, and `#replace` accept + objects which respond to `#to_hash`, even if those objects are not hashes + directly. -* Raise an error when multiple `included` blocks are defined for a Concern. - The old behavior would silently discard previously defined blocks, running - only the last one. + *Peter Jaros* - *Mike Dillon* +* Deprecate `Class#superclass_delegating_accessor`, use `Class#class_attribute` instead. -* Replace `multi_json` with `json`. + *Akshay Vishnoi* - Since Rails requires Ruby 1.9 and since Ruby 1.9 includes `json` in the standard library, - `multi_json` is no longer necessary. +* Ensure classes which `include Enumerable` get `#to_json` in addition to + `#as_json`. - *Erik Michaels-Ober* + *Sammy Larbi* -* Added escaping of U+2028 and U+2029 inside the json encoder. - These characters are legal in JSON but break the Javascript interpreter. - After escaping them, the JSON is still legal and can be parsed by Javascript. +* Change the signature of `fetch_multi` to return a hash rather than an + array. This makes it consistent with the output of `read_multi`. - *Mario Caropreso + Viktor Kelemen + zackham* + *Parker Selbert* -* Fix skipping object callbacks using metadata fetched via callback chain - inspection methods (`_*_callbacks`) +* Introduce `Concern#class_methods` as a sleek alternative to clunky + `module ClassMethods`. Add `Kernel#concern` to define at the toplevel + without chunky `module Foo; extend ActiveSupport::Concern` boilerplate. - *Sean Walbran* + # app/models/concerns/authentication.rb + concern :Authentication do + included do + after_create :generate_private_key + end -* Add a `fetch_multi` method to the cache stores. The method provides - an easy to use API for fetching multiple values from the cache. + class_methods do + def authenticate(credentials) + # ... + end + end - Example: + def generate_private_key + # ... + end + end - # Calculating scores is expensive, so we only do it for posts - # that have been updated. Cache keys are automatically extracted - # from objects that define a #cache_key method. - scores = Rails.cache.fetch_multi(*posts) do |post| - calculate_score(post) + # app/models/user.rb + class User < ActiveRecord::Base + include Authentication end - *Daniel Schierbeck* + *Jeremy Kemper* -Please check [4-0-stable](https://github.com/rails/rails/blob/4-0-stable/activesupport/CHANGELOG.md) for previous changes. +Please check [4-1-stable](https://github.com/rails/rails/blob/4-1-stable/activesupport/CHANGELOG.md) for previous changes. |