Skip to content

Commit

Permalink
update for Faraday v0.9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
technoweenie committed Jan 5, 2013
1 parent 92bbe31 commit 3178b7a
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
10 changes: 7 additions & 3 deletions lib/sawyer/agent.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
require 'faraday'
require 'faraday/autoload'
require 'uri_template'

class Faraday::Env
attr_accessor :sawyer_started, :sawyer_ended
end

module Sawyer
class Agent
NO_BODY = Set.new([:get, :head])
Expand Down Expand Up @@ -97,8 +101,8 @@ def call(method, url, data = nil, options = nil)
end
started = Time.now
end
res.env[:sawyer_started] = started
res.env[:sawyer_ended] = Time.now
res.env.sawyer_started = started
res.env.sawyer_ended = Time.now

Response.new self, res
end
Expand Down
4 changes: 2 additions & 2 deletions lib/sawyer/response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ def process_data(data)
end

def timing
@timing ||= @env[:sawyer_ended] - @env[:sawyer_started]
@timing ||= @env.sawyer_ended - @env.sawyer_started
end

def time
@env[:sawyer_ended]
@env.sawyer_ended
end

def inspect
Expand Down

0 comments on commit 3178b7a

Please sign in to comment.