Skip to content

Commit 17944a2

Browse files
author
Tom Lord
committed
Set limiters within a closure
1 parent 53967e8 commit 17944a2

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

lib/core_extensions/regexp/examples.rb

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,21 @@ module Regexp
55
# No core classes are extended in any way, other than the above two methods.
66
module Examples
77
def examples(**config_options)
8-
RegexpExamples::ResultCountLimiters.configure!(
8+
RegexpExamples::ResultCountLimiters.with_configuration(
99
max_repeater_variance: config_options[:max_repeater_variance],
1010
max_group_results: config_options[:max_group_results],
1111
max_results_limit: config_options[:max_results_limit]
12-
)
13-
examples_by_method(:result)
12+
) do
13+
examples_by_method(:result)
14+
end
1415
end
1516

1617
def random_example(**config_options)
17-
RegexpExamples::ResultCountLimiters.configure!(
18+
RegexpExamples::ResultCountLimiters.with_configuration(
1819
max_repeater_variance: config_options[:max_repeater_variance]
19-
)
20-
examples_by_method(:random_result).sample(1).first
20+
) do
21+
examples_by_method(:random_result).sample
22+
end
2123
end
2224

2325
private

0 commit comments

Comments
 (0)