Class: Oare::Connection

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(token, format = ActiveResource::Formats::XmlFormat) ⇒ Connection

Returns a new instance of Connection.



6
7
8
9
10
11
12
# File 'lib/active_resource_override/connection.rb', line 6

def initialize(token, format = ActiveResource::Formats::XmlFormat)
  @access_token = token
  @user = @password = nil
  @uri_parser = URI.const_defined?(:Parser) ? URI::Parser.new : URI
  self.site = access_token.consumer.site
  self.format = format
end

Instance Attribute Details

#access_tokenObject (readonly)

Returns the value of attribute access_token.



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

def access_token
  @access_token
end

Instance Method Details

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



14
15
16
# File 'lib/active_resource_override/connection.rb', line 14

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

#handle_response(response) ⇒ Object



18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/active_resource_override/connection.rb', line 18

def handle_response(response)
  return super(response)
rescue ActiveResource::ClientError => exc
  begin
    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