Skip to content
This repository
tree: 76e231e086
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 25 lines (20 sloc) 0.601 kb
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
Something went wrong with that request. Please try again.