Class: Merb::Rack::StreamWrapper
- Defined in:
- lib/merb-core/rack/stream_wrapper.rb
Instance Method Summary collapse
-
#==(other) ⇒ Object
:api: private.
-
#each(&callback) ⇒ Object
:api: private.
-
#initialize(body) ⇒ StreamWrapper
constructor
:api: private.
-
#method_missing(sym, *args, &blk) ⇒ Object
:api: private.
-
#to_s ⇒ Object
:api: private.
-
#write(str) ⇒ Object
:api: private.
Constructor Details
#initialize(body) ⇒ StreamWrapper
:api: private
6 7 8 |
# File 'lib/merb-core/rack/stream_wrapper.rb', line 6 def initialize(body) @body = body end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(sym, *args, &blk) ⇒ Object
:api: private
39 40 41 |
# File 'lib/merb-core/rack/stream_wrapper.rb', line 39 def method_missing(sym, *args, &blk) @body.send(sym, *args, &blk) end |
Instance Method Details
#==(other) ⇒ Object
:api: private
34 35 36 |
# File 'lib/merb-core/rack/stream_wrapper.rb', line 34 def ==(other) @body == other end |
#each(&callback) ⇒ Object
:api: private
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/merb-core/rack/stream_wrapper.rb', line 11 def each(&callback) if Proc === @body @writer = lambda { |x| callback.call(x) } @body.call(self) elsif @body.is_a?(String) @body.each_line(&callback) else @body.each(&callback) end end |
#to_s ⇒ Object
:api: private
29 30 31 |
# File 'lib/merb-core/rack/stream_wrapper.rb', line 29 def to_s @body.to_s end |
#write(str) ⇒ Object
:api: private
23 24 25 26 |
# File 'lib/merb-core/rack/stream_wrapper.rb', line 23 def write(str) @writer.call str.to_s str end |