blob: bc69263abbe324d13f49444e759b0f7a835ef101 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
|
module ActiveSupport #:nodoc:
module CoreExtensions #:nodoc:
module Range #:nodoc:
# Return an array when step is called without a block.
module BlocklessStep
def self.included(base) #:nodoc:
base.alias_method_chain :step, :blockless
end
def step_with_blockless(value, &block)
if block_given?
step_without_blockless(value, &block)
else
returning [] do |array|
step_without_blockless(value) { |step| array << step }
end
end
end
end
end
end
end
|