Class: Wrest::Native::Get

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

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, #invoke

Constructor Details

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

Returns a new instance of Get



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

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



12
13
14
# File 'lib/wrest/native/get.rb', line 12

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.


34
35
36
37
38
39
40
41
42
43
# File 'lib/wrest/native/get.rb', line 34

def ==(other)
  return true if self.equal?(other)
  return false unless other.class == self.class
  return true if self.uri == other.uri and
    self.parameters == other.parameters and
    self.username == other.username and
    self.password == other.password and
    self.verify_mode == other.verify_mode
  false
end

#build_request_without_cache_store(cache_validation_headers) ⇒ Object



58
59
60
61
62
63
64
# File 'lib/wrest/native/get.rb', line 58

def build_request_without_cache_store(cache_validation_headers)
  new_headers = headers.clone.merge cache_validation_headers
  new_options = options.clone.tap { |opts| opts.delete :cache_store; opts[:disable_cache] = true } # do not run this through the caching mechanism.

  new_request = Wrest::Native::Get.new(uri, parameters, new_headers, new_options)
  new_request
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.



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

def hash
  self.uri.hash + self.parameters.hash + self.username.hash + self.password.hash + self.verify_mode.hash + 20110106
end

#invoke_with_cache_checkObject

:nodoc:



52
53
54
# File 'lib/wrest/native/get.rb', line 52

def invoke_with_cache_check
  cache_proxy.get
end