There's an echo in my head

日々のメモ。

callの返り値とRack::Response.newの引数の順序

callの返り値の順序とRack::Response.newの引数の順序が違ったのでメモ。*で展開できたら楽だったのになあ。

class GreatMiddleware
  def initialize(app)
    @app = app
  end

  def call(env)
    result = @app.call(env)

    response = Rack::Response.new(result[2], result[0], result[1])
    great_method(response)
    
    return result
  end

  private

  def great_method(response)
    # snip
  end
end
このブログに出てくるコードスニペッツは、引用あるいは断りがない限りMITライセンスです。