diff --git a/lib/pager.rb b/lib/pager.rb index b6a655c..b59dc1e 100644 --- a/lib/pager.rb +++ b/lib/pager.rb @@ -16,6 +16,13 @@ module Enumerable grouped end end unless [].respond_to?(:group_by) + + def group_by_fast + inject({}) do |grouped, element| + (grouped[yield(element)] ||= []) << element + grouped + end + end end class CouchRest diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index b859a9c..22063b9 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -1,4 +1,4 @@ require File.dirname(__FILE__) + '/../lib/couchrest' -COUCHHOST = "http://localhost:5985" +COUCHHOST = "http://localhost:5984" TESTDB = 'couchrest-test' \ No newline at end of file