Explore >> Select a destination


You are here

zverok.space
| | honnef.co
2.2 parsecs away

Travel
| |
| | tenderlovemaking.com
7.1 parsecs away

Travel
| | TL;DR: Rack API is poor when you consider streaming response bodies. class FooApplication class ErbPage def to_a head = "the head tag" sleep(2) body = "the body tag" sleep(2) [head, body] end end def call(env) [200, {}, ErbPage.new.to_a] end end class FakeRack def serve(application) status, headers, body = application.call({}) p :status => status p :headers => headers body.each do |string| p string end body.close if body.respond_to?(:close) end end app = FooApplication.new rack = FakeRack.new rack.serve app $ time ruby foo.rb {:status=>200} {:headers=>{}} "the head tag" "the body tag" real 0m4.008s user 0m0.003s sys 0m0.003s class ResponseTimer def initialize(app) @app = app end def call(env) now = Time.now status, headers, body = @app.call(env) headers['X-R...
| | endofline.wordpress.com
4.3 parsecs away

Travel
| | This article has been republished on Monkey and Crow. As of ruby 1.9, you can do some pretty odd things with array destructuring and splatting. Putting the star before an object invokes the splat operator, which has a variety of effects. First we'll start with some very useful examples, then we will poke around the...
| | www.blackbytes.info
27.7 parsecs away

Travel
| What are Ruby blocks and how do they work? What about Ruby procs & lambdas? What are the differences between these? Find the answers in this post!