Commit bab0d46449a53f7a49f77181413aca000103644b
Exists in
master
and in
1 other branch
Merge pull request #184 from nashby/remove-old-code
remove core_ext/hash
Showing
2 changed files
with
0 additions
and
63 deletions
Show diff stats
config/initializers/requirements.rb
lib/core_ext/hash.rb
| @@ -1,61 +0,0 @@ | @@ -1,61 +0,0 @@ | ||
| 1 | -module CoreExt | ||
| 2 | - module Hash | ||
| 3 | - | ||
| 4 | - | ||
| 5 | - | ||
| 6 | - def pick(*picks) | ||
| 7 | - picks = picks.flatten | ||
| 8 | - picks.inject({}) {|result, key| self.key?(key) ? result.merge(key => self[key]) : result} | ||
| 9 | - end | ||
| 10 | - | ||
| 11 | - | ||
| 12 | - | ||
| 13 | - def pick!(*picks) | ||
| 14 | - picks = picks.flatten | ||
| 15 | - keys.each {|key| self.delete(key) unless picks.member?(key) } | ||
| 16 | - end | ||
| 17 | - | ||
| 18 | - | ||
| 19 | - | ||
| 20 | - def except(*picks) | ||
| 21 | - result = self.dup | ||
| 22 | - result.except!(*picks) | ||
| 23 | - result | ||
| 24 | - end | ||
| 25 | - | ||
| 26 | - | ||
| 27 | - | ||
| 28 | - def except!(*picks) | ||
| 29 | - picks = picks.flatten | ||
| 30 | - keys.each {|key| self.delete(key) if picks.member?(key) } | ||
| 31 | - end | ||
| 32 | - | ||
| 33 | - | ||
| 34 | - | ||
| 35 | - def inspect!(depth=0) | ||
| 36 | - s = "" | ||
| 37 | - self.each do |k,v| | ||
| 38 | - s << (" " * depth) | ||
| 39 | - s << k | ||
| 40 | - s << ": " | ||
| 41 | - if v.is_a?(Hash) | ||
| 42 | - s << "{\n" | ||
| 43 | - s << v.inspect!(depth + 2) | ||
| 44 | - s << (" " * depth) | ||
| 45 | - s << "}" | ||
| 46 | - elsif v.is_a?(Array) | ||
| 47 | - s << v.inspect | ||
| 48 | - else | ||
| 49 | - s << v.to_s | ||
| 50 | - end | ||
| 51 | - s << "\n" | ||
| 52 | - end | ||
| 53 | - s | ||
| 54 | - end | ||
| 55 | - | ||
| 56 | - | ||
| 57 | - | ||
| 58 | - end | ||
| 59 | -end | ||
| 60 | - | ||
| 61 | -Hash.send :include, CoreExt::Hash |