lib/candy/crunch.rb in candy-0.2.4 vs lib/candy/crunch.rb in candy-0.2.5
- old
+ new
@@ -170,11 +170,12 @@
raise ConnectionError, "The collection attribute needs a Mongo::Collection object or a name string."
end
end
# Returns the collection you gave, or creates a default collection named for the current class.
+ # (By which we mean _just_ the class name, not the full module namespace.)
def collection
- @collection ||= db.collection(name)
+ @collection ||= db.collection(name.sub(/^.*::/,''))
end
# Creates an index on the specified property, with an optional direction specified as either :asc or :desc.
# (Note that this is deliberately a very simple method. If you want multi-key or unique indexes, just call
# #create_index directly on the collection.)
\ No newline at end of file