Class: BrmClient::Gateway::Mongo

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ Mongo

Returns a new instance of Mongo.



7
8
9
10
11
12
# File 'lib/brm_client/gateway/mongo.rb', line 7

def initialize opts
  host = opts[:host] || "localhost"
  port = opts[:port] || ::Mongo::Connection::DEFAULT_PORT
  @connection = ::Mongo::Connection.new(host, port)
  @collection = @connection.db(opts[:db] || opts[:application]).collection(opts[:collection] || "logs")
end

Instance Attribute Details

#collectionObject (readonly)

Returns the value of attribute collection.



6
7
8
# File 'lib/brm_client/gateway/mongo.rb', line 6

def collection
  @collection
end

#connectionObject (readonly)

Returns the value of attribute connection.



6
7
8
# File 'lib/brm_client/gateway/mongo.rb', line 6

def connection
  @connection
end

Instance Method Details

#disconnectObject



14
15
# File 'lib/brm_client/gateway/mongo.rb', line 14

def disconnect
end

#send_event(e) ⇒ Object



17
18
19
# File 'lib/brm_client/gateway/mongo.rb', line 17

def send_event e
  collection.insert(e)
end