File tree Expand file tree Collapse file tree 1 file changed +25
-5
lines changed Expand file tree Collapse file tree 1 file changed +25
-5
lines changed Original file line number Diff line number Diff line change @@ -101,6 +101,26 @@ def op_code
101
101
# @since 2.1.0
102
102
class Upconverter
103
103
104
+ # Next batch constant.
105
+ #
106
+ # @since 2.1.0
107
+ NEXT_BATCH = 'nextBatch' . freeze
108
+
109
+ # First batch constant.
110
+ #
111
+ # @since 2.1.0
112
+ FIRST_BATCH = 'firstBatch' . freeze
113
+
114
+ # Cursor field constant.
115
+ #
116
+ # @since 2.1.0
117
+ CURSOR = 'cursor' . freeze
118
+
119
+ # Id field constant.
120
+ #
121
+ # @since 2.1.0
122
+ ID = 'id' . freeze
123
+
104
124
# @return [ Array<BSON::Document> ] documents The documents.
105
125
attr_reader :documents
106
126
@@ -141,20 +161,20 @@ def command
141
161
private
142
162
143
163
def batch_field
144
- starting_from > 0 ? 'nextBatch' : 'firstBatch'
164
+ starting_from > 0 ? NEXT_BATCH : FIRST_BATCH
145
165
end
146
166
147
167
def command?
148
- !documents . empty? && documents . first . key? ( 'ok' )
168
+ !documents . empty? && documents . first . key? ( Operation :: Result :: OK )
149
169
end
150
170
151
171
def find_command
152
172
document = BSON ::Document . new
153
173
cursor_document = BSON ::Document . new
154
- cursor_document . store ( 'id' , cursor_id )
174
+ cursor_document . store ( ID , cursor_id )
155
175
cursor_document . store ( batch_field , documents )
156
- document . store ( 'ok' , 1 )
157
- document . store ( 'cursor' , cursor_document )
176
+ document . store ( Operation :: Result :: OK , 1 )
177
+ document . store ( CURSOR , cursor_document )
158
178
document
159
179
end
160
180
You can’t perform that action at this time.
0 commit comments