Class: OAuthActiveResource::Connection

Inherits:
ActiveResource::Connection
  • Object
show all
Defined in:
lib/oauth_active_resource/connection.rb

Instance Method Summary collapse

Constructor Details

#initialize(oauth_connection, *args) ⇒ Connection

Returns a new instance of Connection.



4
5
6
7
# File 'lib/oauth_active_resource/connection.rb', line 4

def initialize(oauth_connection, *args)    
  @oauth_connection = oauth_connection
  super(*args)
end

Instance Method Details

#get_without_decoding(path, headers = {}) ⇒ Object

an alternative for the get method, which doesnt tries to decode the response



10
11
12
# File 'lib/oauth_active_resource/connection.rb', line 10

def get_without_decoding(path, headers = {})
  request(:get, path, build_request_headers(headers, :get))
end

#handle_response(response) ⇒ Object

make handle_response public and add error message from body if possible



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/oauth_active_resource/connection.rb', line 15

def handle_response(response)
  return super(response)
rescue ActiveResource::ClientError => exc
  begin
    # ugly code to insert the error_message into response
    error_message = "#{format.decode response.body}"
    if not error_message.nil? or error_message == ""
      exc.response.instance_eval do || 
        @message = error_message
      end
    end 
  ensure
    raise exc
  end
end