Skip to content

Commit 76116af

Browse files
committed
Make processing Aggregation options simpler
1 parent 998140a commit 76116af

File tree

1 file changed

+5
-11
lines changed

1 file changed

+5
-11
lines changed

lib/mongo/collection/view/aggregation.rb

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class Aggregation
5858
#
5959
# @since 2.0.0
6060
def allow_disk_use(value = nil)
61-
configure(OPTIONS_MAP[__method__], value)
61+
configure(__method__, value)
6262
end
6363

6464
# Initialize the aggregation for the provided collection view, pipeline
@@ -99,19 +99,13 @@ def aggregate_spec
9999
:aggregate => collection.name,
100100
:pipeline => pipeline,
101101
:cursor => cursor,
102-
}.merge!(process_options)
102+
}.merge!(agg_options)
103103
}
104104
end
105105

106-
def process_options
107-
@agg_options ||= @options.each.reduce({}) do |opts, (key, value)|
108-
if OPTIONS_MAP[key]
109-
opts.merge(OPTIONS_MAP[key] => value)
110-
elsif OPTIONS_MAP.values.include?(key)
111-
opts.merge(key => value)
112-
else
113-
opts
114-
end
106+
def agg_options
107+
@agg_options ||= options.each.reduce({}) do |opts, (key, value)|
108+
OPTIONS_MAP[key] ? opts.merge!(OPTIONS_MAP[key] => value) : opts
115109
end
116110
end
117111

0 commit comments

Comments
 (0)