Class: RemoteResource::AttributeHttpClient

Inherits:
Object
  • Object
show all
Includes:
Notifications
Defined in:
lib/remote_resource/attribute_http_client.rb

Instance Method Summary collapse

Methods included from Notifications

#instrument, #instrument_attribute

Constructor Details

#initialize(attribute, client = nil) ⇒ AttributeHttpClient

Returns a new instance of AttributeHttpClient.



7
8
9
10
11
# File 'lib/remote_resource/attribute_http_client.rb', line 7

def initialize(attribute, client = nil)
  @attribute = attribute
  @client = client || @attribute.client
  @resource_name = @attribute.resource_name
end

Instance Method Details

#get(headers = {}) ⇒ Object



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/remote_resource/attribute_http_client.rb', line 13

def get(headers = {})
  instrument_attribute('http_get', @attribute) do
    if headers && headers.size > 0
      with_headers_for_method(:get, headers) do |client|
        @attribute.resource(client)
      end
    else
      @attribute.resource(@client)
    end
  end
  @client.last_response
end