class Synapse::Common::Mongo::BaseTemplate

Represents a mechanism for accessing collections required by a component @abstract

Attributes

database_name[RW]

@return [String] Name of the database to use

password[RW]

@return [String] Password to authenticate with (optional)

username[RW]

@return [String] Username to authenticate with (optional)

Public Class Methods

new(client) click to toggle source

@param [Mongo::MongoClient] client @return [undefined]

# File lib/synapse/common/mongo/base_template.rb, line 18
def initialize(client)
  @client = client
  @database_name = 'synapse'
end

Protected Instance Methods

database() click to toggle source

@return [Mongo::DB]

# File lib/synapse/common/mongo/base_template.rb, line 26
def database
  unless @database
    @database = @client.db @database_name

    if @username and @password
      @database.authenticate @username, @password
    end
  end

  @database
end