@@ -18,16 +18,10 @@ module Write
18
18
module Bulk
19
19
class Delete
20
20
21
- # Defines custom behaviour of results when deleting .
21
+ # Defines common r_removed aggreation behaviour .
22
22
#
23
- # @since 2.0.0
24
- class Result < Operation ::Result
25
- include Mergable
26
-
27
- # The aggregate number of deleted docs reported in the replies.
28
- #
29
- # @since 2.0.0
30
- REMOVED = 'nRemoved' . freeze
23
+ # @since 2.2.0
24
+ module Aggregatable
31
25
32
26
# Gets the number of documents deleted.
33
27
#
@@ -40,32 +34,31 @@ class Result < Operation::Result
40
34
def n_removed
41
35
return 0 unless acknowledged?
42
36
@replies . reduce ( 0 ) do |n , reply |
43
- n += reply . documents . first [ N ]
37
+ n += reply . documents . first [ Result :: N ]
44
38
end
45
39
end
46
40
end
47
41
48
42
# Defines custom behaviour of results when deleting.
49
- # For server versions < 2.5.5 (that don't use write commands).
50
43
#
51
44
# @since 2.0.0
52
- class LegacyResult < Operation ::Result
53
- include LegacyMergable
45
+ class Result < Operation ::Result
46
+ include Mergable
47
+ include Aggregatable
54
48
55
- # Gets the number of documents deleted.
56
- #
57
- # @example Get the deleted count.
58
- # result.n_removed
59
- #
60
- # @return [ Integer ] The number of documents deleted.
49
+ # The aggregate number of deleted docs reported in the replies.
61
50
#
62
51
# @since 2.0.0
63
- def n_removed
64
- return 0 unless acknowledged?
65
- @replies . reduce ( 0 ) do |n , reply |
66
- n += reply . documents . first [ N ]
67
- end
68
- end
52
+ REMOVED = 'nRemoved' . freeze
53
+ end
54
+
55
+ # Defines custom behaviour of results when deleting.
56
+ # For server versions < 2.5.5 (that don't use write commands).
57
+ #
58
+ # @since 2.0.0
59
+ class LegacyResult < Operation ::Result
60
+ include LegacyMergable
61
+ include Aggregatable
69
62
end
70
63
end
71
64
end
0 commit comments