Class: Wrest::Native::Get

Inherits:
Request
  • Object
show all
Defined in:
lib/wrest/native/get.rb

Constant Summary collapse

QUERY_PARAMS_SEPERATOR =
'?'
EMPTY_QUERY_PARAMS =
''

Instance Attribute Summary collapse

Attributes inherited from Request

#body, #ca_path, #cache_store, #connection, #follow_redirects, #follow_redirects_count, #follow_redirects_limit, #headers, #http_request, #options, #parameters, #password, #timeout, #uri, #username, #verify_mode

Instance Method Summary collapse

Methods inherited from Request

#build_request, #do_request, #execute_callback_if_any

Constructor Details

#initialize(wrest_uri, parameters = {}, headers = {}, options = {}) ⇒ Get

Returns a new instance of Get.



19
20
21
22
23
24
25
26
27
# File 'lib/wrest/native/get.rb', line 19

def initialize(wrest_uri, parameters = {}, headers = {}, options = {})
  follow_redirects = options[:follow_redirects]
  options[:follow_redirects] = (follow_redirects.nil? ? true : follow_redirects)

  cache_store = (options[:cache_store] || Wrest::Caching.default_store) unless options[:disable_cache]
  @cache_proxy = Wrest::CacheProxy.new(self, cache_store)

  super(wrest_uri, Net::HTTP::Get, parameters, nil, headers, options)
end

Instance Attribute Details

#cache_proxyObject (readonly)

Returns the value of attribute cache_proxy.



17
18
19
# File 'lib/wrest/native/get.rb', line 17

def cache_proxy
  @cache_proxy
end

Instance Method Details

#==(other) ⇒ Object

Checks equality between two Wrest::Native::Get objects. Comparing two Wrest::Native::Get objects with identical values for the following properties would return True.

uri, parameters, username, password and ssh verify_mode.


32
33
34
35
36
37
38
# File 'lib/wrest/native/get.rb', line 32

def ==(other)
  return true if equal?(other)
  return false unless other.class == self.class
  return true if these_fields_are_equal(other)

  false
end

#build_request_without_cache_store(cache_validation_headers) ⇒ Object



54
55
56
57
58
59
60
61
62
# File 'lib/wrest/native/get.rb', line 54

def build_request_without_cache_store(cache_validation_headers)
  new_headers = headers.clone.merge cache_validation_headers
  new_options = # do not run this through the caching mechanism.
    options.clone.tap do |opts|
      opts.delete :cache_store
      opts[:disable_cache] = true
    end
  Wrest::Native::Get.new(uri, parameters, new_headers, new_options)
end

#full_uri_stringObject



64
65
66
# File 'lib/wrest/native/get.rb', line 64

def full_uri_string
  @uri.to_s + query_params_string
end

#hashObject

Returns a hash value for this Wrest::Native::Get object. Objects that returns true when compared using the == operator would return the same hash value also.



42
43
44
# File 'lib/wrest/native/get.rb', line 42

def hash
  [uri, parameters, username, password, verify_mode].hash
end

#invoke_with_cache_checkObject Also known as: invoke

:nodoc:



47
48
49
# File 'lib/wrest/native/get.rb', line 47

def invoke_with_cache_check
  cache_proxy.get
end