Skip to content

Commit

Permalink
Merge pull request #449 from zzak/body_proxy_each
Browse files Browse the repository at this point in the history
Rack::BodyProxy#each, fixes #434
  • Loading branch information
raggi committed Nov 2, 2012
2 parents a9df5f1 + afc9b03 commit d186029
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/rack/body_proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,14 @@ def closed?
@closed
end

# N.B. This method is a special case to address the bug described by #434.
# We are applying this special case for #each only. Future bugs of this
# class will be handled by requesting users to patch their ruby
# implementation, to save adding too many methods in this class.
def each(*args, &block)
@body.each(*args, &block)
end

def method_missing(*args, &block)
super if args.first.to_s =~ /^to_ary$/
@body.__send__(*args, &block)
Expand Down
4 changes: 4 additions & 0 deletions test/spec_body_proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -62,4 +62,8 @@ def object.close() raise "No!" end
proxy.close
closed.should.equal true
end

should 'provide an #each method' do
Rack::BodyProxy.method_defined?(:each).should.equal true
end
end

0 comments on commit d186029

Please sign in to comment.