Module: Flickr::Configuration

Included in:
Flickr
Defined in:
lib/flickr/configuration.rb

Overview

Provides general configuration options for the library.

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#access_token_keyObject

Required for authenticated requests.

config.access_token_key    = "KEY"
config.access_token_secret = "SECRET"

For details on how to obtain it, take a look at the OAuth module.



37
38
39
# File 'lib/flickr/configuration.rb', line 37

def access_token_key
  @access_token_key
end

#access_token_secretObject

Required for authenticated requests.

config.access_token_key    = "KEY"
config.access_token_secret = "SECRET"

For details on how to obtain it, take a look at the OAuth module.



37
38
39
# File 'lib/flickr/configuration.rb', line 37

def access_token_secret
  @access_token_secret
end

#api_keyObject

API key and shared secret are necessary for making API requests. You can apply for them here.



27
28
29
# File 'lib/flickr/configuration.rb', line 27

def api_key
  @api_key
end

#cacheObject

Enables caching responses. An object that is passed must respond to #read, #write and #fetch.

config.cache = ActiveSupport::Cache::MemoryStore.new(expires_in: 1.hour)


100
101
102
# File 'lib/flickr/configuration.rb', line 100

def cache
  @cache
end

#open_timeoutObject

Time to wait for the connection to Flickr to open. After that TimeoutError is thrown.

Default is 5 seconds.



55
56
57
# File 'lib/flickr/configuration.rb', line 55

def open_timeout
  @open_timeout
end

#paginationObject

When retrieving photos from Flickr, you can enable automatic compatibility with a pagination library.

config.pagination = :will_paginate

Supports WillPaginate and Kaminari.



92
93
94
# File 'lib/flickr/configuration.rb', line 92

def pagination
  @pagination
end

#proxyObject

You can choose to go over a proxy.

config.proxy = "http://proxy.com"


79
80
81
# File 'lib/flickr/configuration.rb', line 79

def proxy
  @proxy
end

#shared_secretObject

API key and shared secret are necessary for making API requests. You can apply for them here.



27
28
29
# File 'lib/flickr/configuration.rb', line 27

def shared_secret
  @shared_secret
end

#timeoutObject

Time to wait for the first block of response from Flickr. After that TimeoutError is thrown.

Default is 10 seconds.



62
63
64
# File 'lib/flickr/configuration.rb', line 62

def timeout
  @timeout
end

#use_sslObject

You can choose to make requests over a secure connection (SSL).

config.use_ssl = true

Default is false.



71
72
73
# File 'lib/flickr/configuration.rb', line 71

def use_ssl
  @use_ssl
end

Instance Method Details

#access_tokenArray(string, string)

Returns:

  • (Array(string, string))


43
44
45
46
47
# File 'lib/flickr/configuration.rb', line 43

def access_token
  if access_token_key and access_token_secret
    [access_token_key, access_token_secret]
  end
end

#configure {|_self| ... } ⇒ Object

Examples:

Flickr.configure do |config|
  config.api_key = "..."
  config.shared_secret = "..."
  # ...
end

Yields:

  • (_self)

Yield Parameters:



16
17
18
19
# File 'lib/flickr/configuration.rb', line 16

def configure
  yield self
  self
end