received 0.3.3 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/received/backend/mongodb.rb +4 -3
- data/lib/received/connection.rb +1 -0
- data/lib/received/version.rb +1 -1
- metadata +1 -1
@@ -11,8 +11,8 @@ module Received
|
|
11
11
|
# @option params [String] database
|
12
12
|
# @option params [String] collection
|
13
13
|
def initialize(params)
|
14
|
-
|
15
|
-
@coll =
|
14
|
+
db = Mongo::Connection.new(params['host']).db(params['database'])
|
15
|
+
@coll = db.collection(params['collection'])
|
16
16
|
end
|
17
17
|
|
18
18
|
# Store mail in MongoDB
|
@@ -20,7 +20,8 @@ module Received
|
|
20
20
|
# @param [Hash] mail
|
21
21
|
# @return [ObjectId] object_id
|
22
22
|
def store(mail)
|
23
|
-
|
23
|
+
mail = mail.merge(:ts => Time.now.to_i, :body => BSON::Binary.new(mail[:body]))
|
24
|
+
@coll.insert(mail, :safe => {:fsync => true})
|
24
25
|
end
|
25
26
|
end
|
26
27
|
end
|
data/lib/received/connection.rb
CHANGED
data/lib/received/version.rb
CHANGED