lib/dolly/collection.rb in dolly-0.7.6 vs lib/dolly/collection.rb in dolly-0.8.0

- old
+ new

@@ -23,10 +23,16 @@ def map &block load if empty? @set.collect &block end + alias_method :collect, :map + + def flat_map &block + map( &block ).flatten + end + def each &block load if empty? @set.each &block #TODO: returning nil to avoid extra time serializing set. nil @@ -46,11 +52,10 @@ ary.each do |r| next unless r['doc'] properties = r['doc'] id = properties.delete '_id' rev = properties.delete '_rev' if properties['_rev'] - doc_class = doc_class id - document = doc_class.new properties + document = (docs_class || doc_class(id)).new properties document.doc = properties.merge({'_id' => id, '_rev' => rev}) @set << document end @rows = ary end