@@ -48,7 +48,11 @@ def initialize(cursor)
48
48
#
49
49
# @since 2.2.0
50
50
def specification
51
- { :coll_name => collection_name , :db_name => database . name , :cursor_ids => [ cursor . id ] }
51
+ {
52
+ coll_name : collection_name ,
53
+ db_name : database . name ,
54
+ cursor_ids : [ BSON ::Int64 . new ( cursor . id ) ] ,
55
+ }
52
56
end
53
57
54
58
class << self
@@ -59,23 +63,31 @@ class << self
59
63
# OpKillCursors.update_cursors(spec, ids)
60
64
#
61
65
# @return [ Hash ] The specification.
62
- # @return [ Array ] The ids to update with.
66
+ # @return [ Array<Integer> ] The ids to update with.
63
67
#
64
68
# @since 2.3.0
65
69
def update_cursors ( spec , ids )
66
- spec . merge! ( cursor_ids : spec [ :cursor_ids ] & ids )
70
+ # Ruby 2.5+ can & BSON::Int64 instances.
71
+ # Ruby 2.4 and earlier cannot.
72
+ # Convert stored ids to Ruby integers for compatibility with
73
+ # older Rubies.
74
+ ids = get_cursors_list ( spec ) & ids
75
+ ids = ids . map do |cursor_id |
76
+ BSON ::Int64 . new ( cursor_id )
77
+ end
78
+ spec . merge! ( cursor_ids : ids )
67
79
end
68
80
69
81
# Get the list of cursor ids from a spec generated by this Builder.
70
82
#
71
83
# @example Get the list of cursor ids.
72
84
# OpKillCursors.cursors(spec)
73
85
#
74
- # @return [ Hash ] The specification .
86
+ # @return [ Array<Integer> ] The cursor ids .
75
87
#
76
88
# @since 2.3.0
77
89
def get_cursors_list ( spec )
78
- spec [ :cursor_ids ]
90
+ spec [ :cursor_ids ] . map ( & :value )
79
91
end
80
92
end
81
93
end
0 commit comments