fix Builder#initialize with block

This commit is contained in:
Mislav Marohnić 2011-03-02 00:12:51 +01:00
parent 198546900c
commit 692199bd08
2 changed files with 2 additions and 4 deletions

View File

@ -52,7 +52,7 @@ module Faraday
def initialize(handlers = [])
@handlers = handlers
@inner_app = self.class.inner_app
build(Proc.new) if block_given?
build(&Proc.new) if block_given?
end
def build(options = {})

View File

@ -33,9 +33,7 @@ module Faraday
merge_headers @headers, options[:headers] if options[:headers]
if block_given?
block = Proc.new
@builder = Builder.new
@builder.build { block.call(self) }
@builder = Builder.create { |b| yield b }
else
@builder = options[:builder] || Builder.new
end