aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--actionpack/lib/action_controller/metal/streaming.rb43
-rw-r--r--actionpack/test/controller/new_base/render_streaming_test.rb2
2 files changed, 6 insertions, 39 deletions
diff --git a/actionpack/lib/action_controller/metal/streaming.rb b/actionpack/lib/action_controller/metal/streaming.rb
index 0bb436a476..5fe5334458 100644
--- a/actionpack/lib/action_controller/metal/streaming.rb
+++ b/actionpack/lib/action_controller/metal/streaming.rb
@@ -24,20 +24,8 @@ module ActionController #:nodoc:
#
# == Examples
#
- # Streaming can be added to a controller easily, all you need to do is
- # call +stream+ in the controller class:
- #
- # class PostsController
- # stream
- # end
- #
- # The +stream+ method accepts the same options as +before_filter+ and friends:
- #
- # class PostsController
- # stream :only => :index
- # end
- #
- # You can also selectively turn on streaming for specific actions:
+ # Streaming can be added to a given template easily, all you need to do is
+ # to pass the :stream option.
#
# class PostsController
# def index
@@ -72,6 +60,9 @@ module ActionController #:nodoc:
# render :stream => true
# end
#
+ # Notice that :stream only works with templates. Rendering :json
+ # or :xml with :stream won't work.
+ #
# == Communication between layout and template
#
# When streaming, rendering happens top-down instead of inside-out.
@@ -209,33 +200,9 @@ module ActionController #:nodoc:
extend ActiveSupport::Concern
include AbstractController::Rendering
- attr_internal :stream
-
- module ClassMethods
- # Render streaming templates. It accepts :only, :except, :if and :unless as options
- # to specify when to stream, as in ActionController filters.
- def stream(options={})
- if defined?(Fiber)
- before_filter :_stream_filter, options
- else
- raise "You cannot use streaming if Fiber is not available."
- end
- end
- end
protected
- # Mark following render calls as streaming.
- def _stream_filter #:nodoc:
- self.stream = true
- end
-
- # Consider the stream option when normalazing options.
- def _normalize_options(options) #:nodoc:
- super
- options[:stream] = self.stream unless options.key?(:stream)
- end
-
# Set proper cache control and transfer encoding when streaming
def _process_options(options) #:nodoc:
super
diff --git a/actionpack/test/controller/new_base/render_streaming_test.rb b/actionpack/test/controller/new_base/render_streaming_test.rb
index 48cf0ab9cb..1a17e24914 100644
--- a/actionpack/test/controller/new_base/render_streaming_test.rb
+++ b/actionpack/test/controller/new_base/render_streaming_test.rb
@@ -10,9 +10,9 @@ module RenderStreaming
)]
layout "application"
- stream :only => [:hello_world, :skip]
def hello_world
+ render :stream => true
end
def layout_exception