blob: d51ea2e94403574a663f7ddb8e24d5db6819ecca (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
require 'active_support/core_ext/module/aliasing'
require 'active_support/core_ext/object/acts_like'
class Range #:nodoc:
def each_with_time_with_zone(&block)
ensure_iteration_allowed
each_without_time_with_zone(&block)
end
alias_method_chain :each, :time_with_zone
def step_with_time_with_zone(n = 1, &block)
ensure_iteration_allowed
step_without_time_with_zone(n, &block)
end
alias_method_chain :step, :time_with_zone
private
def ensure_iteration_allowed
if first.acts_like?(:time)
raise TypeError, "can't iterate from #{first.class}"
end
end
end
|