0.0
No commit activity in last 3 years
No release in over 3 years
Hotfixes and common idioms for the Ruby language.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 10.0
~> 3.3
~> 0.8.7.6
 Project Readme

Ruby Quirks

Build Status Gem Version

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 #reject or #select against an instance of a class that inherits from Hash will return an object of type Hash, rather than an object of the same type that #reject or #select was called against. e.g. This broke Rails' HashWithIndifferentAccess. See this question for more details.

  • What this hotfix does: It overrides #reject and #select of implementing classes to use #dup to return an object of the same type. This effectively replicates pre-2.2 behavior of Hash.

  • How to implement: Include the RubyQuirks::Hash::EnumByDup in your class that inherits from Hash

  • 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