Posted by sorah on 10 Mar 2014
In Ruby 2.1.0 or earlier, the
reject method in any class that inherits
Hash returns an object of its own class.
But in Ruby 2.1.1, this behavior has changed accidentally to return always
a plain Hash object, not of the inherited class.
(To be exact, extra states such as instance variables, etc. aren’t copied either.)
Ruby 2.1.1 shouldn’t include such behavior changes, because with the release of Ruby 2.1.0 we’ve changed our versioning policy, so Ruby 2.1.1 is a patch level release and it shouldn’t break backwards compatibility.
This regression could potentially affect many libraries, one such case is
OrderedHash. They are broken:
Rails’ issue #14188.
This behavior will be reverted to the 2.1.0 behavior in Ruby 2.1.2, but is expected to be the default behavior for Ruby 2.2.0: Feature #9223. So we recommend to fix your code in order to expect this behavior change.
This accident is caused by one missing backport commit. For more details, see http://blog.sorah.jp/2014/03/10/hash-reject-regression-in-ruby211.
Sorry for any inconvenience, and thank you for your support.