# Time travel technology.
#
# Example usage:
# time_tomorrow = TimeTravel.travel(1.day.from_now) { Time.now }

module TimeTravel
  def self.travel time
    if time.is_a? Time
      # How many seconds until the given time?
      time -= Time.now
    end

    # FIXME: no support for going back in time just yet.
    if time < 0
      raise ArgumentError, "Can't go back in time"
    end

    # Travel in time.
    sleep time

    yield
  end
end