Ruby Quirks
For Ruby 1.9.3, 2.0.x, 2.1.x, 2.2.x
Introduction
ruby_quirks is a gem which adds a collection of optional Ruby hotfixes and common idioms to accommodate for some of Ruby's quirky behaviors. See the list below to see what's offered.
Hotfixes
Hash#reject and Hash#select returns Hash for subclasses of Hash
-
For Ruby versions: 2.2.0+
-
Description: Calling
#rejector#selectagainst an instance of a class that inherits fromHashwill return an object of typeHash, rather than an object of the same type that#rejector#selectwas called against. e.g. This broke Rails'HashWithIndifferentAccess. See this question for more details. -
What this hotfix does: It overrides
#rejectand#selectof implementing classes to use#dupto return an object of the same type. This effectively replicates pre-2.2 behavior ofHash. -
How to implement: Include the
RubyQuirks::Hash::EnumByDupin your class that inherits fromHash -
Example:
module CustomHash < Hash include RubyQuirks::Hash::EnumByDup end
Changelog
Version 0.0.2
- Fixed: Namespace not loading (whoops!)
Version 0.0.1
- Initial version of Ruby Quirks
- Added:
RubyQuirks::Hash::EnumByDup