Skip to content

Commit 2667e66

Browse files
committed
Use constants in succeeded events
1 parent 7b2e165 commit 2667e66

File tree

2 files changed

+9
-2
lines changed

2 files changed

+9
-2
lines changed

lib/mongo/collection.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,11 @@ class Collection
3030
# @since 2.1.0
3131
CAPPED = 'capped'.freeze
3232

33+
# The ns field constant.
34+
#
35+
# @since 2.1.0
36+
NS = 'ns'.freeze
37+
3338
# @return [ Mongo::Database ] The database the collection resides in.
3439
attr_reader :database
3540

lib/mongo/monitoring/event/command_succeeded.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,13 @@ def self.generate_reply(command_payload, reply_payload)
9898
if reply_payload
9999
reply = reply_payload[:reply]
100100
if cursor = reply[:cursor]
101-
cursor.merge!('ns' => namespace(command_payload)) if !cursor.key?('ns')
101+
if !cursor.key?(Collection::NS)
102+
cursor.merge!(Collection::NS => namespace(command_payload))
103+
end
102104
end
103105
reply
104106
else
105-
BSON::Document.new(ok: 1)
107+
BSON::Document.new(Operation::Result::OK => 1)
106108
end
107109
end
108110

0 commit comments

Comments
 (0)