Sha256: f3bbf79c83f924e369db3e67a6773f3529ebaf616dc460fec70a681f4dd12164

Contents?: true

Size: 469 Bytes

Versions: 2

Compression:

Stored size: 469 Bytes

Contents

class ObjCursor
  attr_accessor :cursor
  include FromHash
  def each
    cursor.each { |x| yield(x.to_mongo_object) }
  end
  def to_a
    res = []
    each { |x| res << x }
    res
  end
  def count
    cursor.count
  end
end

module MongoPersistCollection
  def find_objects(*args)
    ObjCursor.new(:cursor => find(*args))
  end
  def find_one_object(*args)
    find_one(*args).to_mongo_object
  end
end

class Mongo::Collection
  include MongoPersistCollection
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
mongo_persist-0.2.1 lib/mongo_persist/mongo_ext.rb
mongo_persist-0.2.0 lib/mongo_persist/mongo_ext.rb