Skip to content

Commit

Permalink
fixed bug with convenience methods on Resourceful
Browse files Browse the repository at this point in the history
  • Loading branch information
pezra committed Jan 26, 2010
1 parent 14f8bde commit b2766cc
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions lib/resourceful/resource.rb
Expand Up @@ -135,6 +135,19 @@ def logger
accessor.logger
end

# Actually make the request
def request(method, data, header)
header = default_header.merge(header)
ensure_content_type(data, header) if data

data = StringIO.new(data) if data.kind_of?(String)

log_request_with_time "#{method.to_s.upcase} [#{uri}]" do
request = Request.new(method, self, data, header)
request.fetch_response
end
end

private

# Ensures that the request has a content type header
Expand All @@ -152,19 +165,6 @@ def ensure_content_type(body, header)
raise MissingContentType
end

# Actually make the request
def request(method, data, header)
header = default_header.merge(header)
ensure_content_type(data, header) if data

data = StringIO.new(data) if data.kind_of?(String)

log_request_with_time "#{method.to_s.upcase} [#{uri}]" do
request = Request.new(method, self, data, header)
request.fetch_response
end
end

# Log it took the time to make the request
def log_request_with_time(msg, indent = 2)
logger.info(" " * indent + msg)
Expand Down

0 comments on commit b2766cc

Please sign in to comment.