Newer
Older
2018-fumichan-thesis / form-sample / vendor / bundle / ruby / 2.5.0 / gems / activesupport-5.2.1 / lib / active_support / core_ext / range / each.rb
# frozen_string_literal: true

require "active_support/time_with_zone"

module ActiveSupport
  module EachTimeWithZone #:nodoc:
    def each(&block)
      ensure_iteration_allowed
      super
    end

    def step(n = 1, &block)
      ensure_iteration_allowed
      super
    end

    private

      def ensure_iteration_allowed
        raise TypeError, "can't iterate from #{first.class}" if first.is_a?(TimeWithZone)
      end
  end
end

Range.prepend(ActiveSupport::EachTimeWithZone)