Module: ConveyClient

Defined in:
lib/convey_client.rb,
lib/convey_client/item.rb,
lib/convey_client/items.rb,
lib/convey_client/request.rb,
lib/convey_client/request_error.rb

Defined Under Namespace

Classes: Configuration, Item, Items, Request, RequestError

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.configObject

Returns the value of attribute config.



9
10
11
# File 'lib/convey_client.rb', line 9

def config
  @config
end

Class Method Details

.auth_tokenObject



41
42
43
# File 'lib/convey_client.rb', line 41

def self.auth_token
  config.auth_token
end

.base_urlObject



17
18
19
# File 'lib/convey_client.rb', line 17

def self.base_url
  "http://#{config.subdomain}.convey.io/api/"
end

.cache(key, content) ⇒ Object



33
34
35
36
37
38
39
# File 'lib/convey_client.rb', line 33

def self.cache(key, content)
  return unless config.cache

  options = {}
  options[:expires_in] = config.cache_timeout if config.cache_timeout
  config.cache.store(key, content, options)
end

.cached?(key) ⇒ Boolean

Returns:

  • (Boolean)


21
22
23
24
25
# File 'lib/convey_client.rb', line 21

def self.cached?(key)
  return false unless config.cache

  !config.cache[key].nil? && !config.cache[key].empty?
end

.cached_response(key) ⇒ Object



27
28
29
30
31
# File 'lib/convey_client.rb', line 27

def self.cached_response(key)
  return unless cached?(key)

  config.cache[key]
end

.raise_request_errorsObject



49
50
51
# File 'lib/convey_client.rb', line 49

def self.raise_request_errors
  config.raise_request_errors
end

.setup {|config| ... } ⇒ Object

Yields:



12
13
14
15
# File 'lib/convey_client.rb', line 12

def self.setup
  self.config = Configuration.new
  yield(config)
end

.subdomainObject



45
46
47
# File 'lib/convey_client.rb', line 45

def self.subdomain
  config.subdomain
end