module Mongo::DocumentClass
Public Instance Methods
client()
click to toggle source
# File lib/mongo/document.rb, line 9 def client if !@client raise "No connection! You should call Mongo::Document.establish_connection before." end @client end
Also aliased as: connection
collection()
click to toggle source
# File lib/mongo/document.rb, line 17 def collection @collection ||= client[collection_name] end
collection_name()
click to toggle source
# File lib/mongo/document.rb, line 21 def collection_name @collection_name ||= name.underscore.pluralize end
collection_name=(name)
click to toggle source
# File lib/mongo/document.rb, line 25 def collection_name=(name) @collection_name = name end
find(*args)
click to toggle source
A little optimazation for the most frequently-used method.
# File lib/mongo/document.rb, line 30 def find(*args) collection.find(*args) end
method_missing(name, *args)
click to toggle source
For other methods on collection(or not), just send to it.
# File lib/mongo/document.rb, line 35 def method_missing(name, *args) collection.send(name, *args) end
respond_to_missing?(name, include_private = false)
click to toggle source
Calls superclass method
# File lib/mongo/document.rb, line 39 def respond_to_missing?(name, include_private = false) collection.respond_to?(name, include_private) || super end