Class: Mongo::Collection

Inherits:
Object
  • Object
show all
Defined in:
lib/mongo/collection.rb

Overview

Represents a collection in the database and operations that can directly be applied to one.

Since:

  • 3.0.0

Defined Under Namespace

Classes: InvalidName

Instance Attribute Summary (collapse)

Instance Method Summary (collapse)

Constructor Details

- (Collection) initialize(database, name)

@todo: durran: implement.

Raises:

Since:

  • 3.0.0



45
46
47
48
49
# File 'lib/mongo/collection.rb', line 45

def initialize(database, name)
  raise InvalidName.new unless name
  @database = database
  @name = name.to_s
end

Instance Attribute Details

- (Mongo::Database) database (readonly)

Returns The database the collection resides in.

Since:

  • 3.0.0



24
25
26
# File 'lib/mongo/collection.rb', line 24

def database
  @database
end

- (String) name (readonly)

Returns The name of the collection.

Since:

  • 3.0.0



26
27
28
# File 'lib/mongo/collection.rb', line 26

def name
  @name
end

Instance Method Details

- (true, false) ==(other)

Check if a collection is equal to another object. Will check the name and the database for equality.

Examples:

Check collection equality.

collection == other

Since:

  • 3.0.0



39
40
41
42
# File 'lib/mongo/collection.rb', line 39

def ==(other)
  return false unless other.is_a?(Collection)
  name == other.name && database == other.database
end