Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Ruby 1.9 compatibility: Hash#_select

Signed-off-by: Snax Fauna <evan+fauna@cloudbur.st>
  • Loading branch information...
commit bcd951c4c84230252e027d5d5dde39b61bf65126 1 parent 1801e18
@Nielsomat Nielsomat authored Snax Fauna committed
Showing with 7 additions and 3 deletions.
  1. +7 −3 lib/has_many_polymorphs/support_methods.rb
View
10 lib/has_many_polymorphs/support_methods.rb
@@ -45,9 +45,13 @@ class Hash
# An implementation of select that returns a Hash.
def _select
- Hash[*self.select do |key, value|
- yield key, value
- end._flatten_once]
+ if RUBY_VERSION >= "1.9"
+ Hash[*self.select {|k, v| yield k, v }.flatten]
+ else
+ Hash[*self.select do |key, value|
+ yield key, value
+ end._flatten_once]
+ end
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.