Module: Wrest::Uri::Builders

Included in:
Wrest::Uri
Defined in:
lib/wrest/uri/builders.rb

Overview

Contains methods that depend on Uri#clone to build new Uris configured in particular ways.

Instance Method Summary collapse

Instance Method Details

#disable_cacheObject

Disables using the globally configured cache for GET requests made using the Uri returned by this method.



38
39
40
# File 'lib/wrest/uri/builders.rb', line 38

def disable_cache
  clone(disable_cache: true)
end

Sets the specified string as the cookie for the Uri



43
44
45
# File 'lib/wrest/uri/builders.rb', line 43

def using_cookie(cookie_string)
  clone(default_headers: { Wrest::H::Cookie => cookie_string })
end

#using_emObject

Returns a Uri object that uses eventmachine to perform asynchronous requests. Remember to do Wrest::AsyncRequest.enable_em first so that EventMachine is available for use.



16
17
18
# File 'lib/wrest/uri/builders.rb', line 16

def using_em
  clone(asynchronous_backend: Wrest::AsyncRequest::EventMachineBackend.new)
end

#using_hashObject

Returns a Uri object that uses hash for caching responses.



21
22
23
# File 'lib/wrest/uri/builders.rb', line 21

def using_hash
  clone(cache_store: {})
end

#using_memcachedObject

Returns a Uri object that uses memcached for caching responses. Remember to do Wrest::AsyncRequest.enable_memcached first so that memcached is available for use.



28
29
30
# File 'lib/wrest/uri/builders.rb', line 28

def using_memcached
  clone(cache_store: Wrest::Caching::Memcached.new)
end

#using_redisObject



32
33
34
# File 'lib/wrest/uri/builders.rb', line 32

def using_redis
  clone(cache_store: Wrest::Caching::Redis.new)
end

#using_threadsObject

Returns a Uri object that uses threads to perform asynchronous requests.



9
10
11
# File 'lib/wrest/uri/builders.rb', line 9

def using_threads
  clone(asynchronous_backend: Wrest::AsyncRequest::ThreadBackend.new)
end