Module: Zdi

Defined in:
lib/zentradi.rb,
lib/zentradi/collection.rb,
lib/zentradi/document_helpers.rb,
lib/zentradi/document_wrapper.rb

Defined Under Namespace

Modules: DocumentHelpers Classes: Collection, DocumentWrapper

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.default_databaseObject

Returns the value of attribute default_database.



10
11
12
# File 'lib/zentradi.rb', line 10

def default_database
  @default_database
end

Class Method Details

.Collection(collection, database = Zdi.default_database) ⇒ Object

Raises:

  • (ArgumentError)


12
13
14
15
# File 'lib/zentradi.rb', line 12

def Collection(collection, database = Zdi.default_database)
  raise ArgumentError, "please provide a database. The default one is #{database.inspect}" unless database.is_a?(Mongo::DB)
  Class.new(Zdi::Collection) { instance_variable_set("@collection", database[collection]) }
end