Module: TumblrOAuth::Configuration

Included in:
TumblrOAuth
Defined in:
lib/tumblr-oauth/configuration.rb

Constant Summary collapse

VALID_OPTIONS_KEYS =
[
  :consumer_key,
  :consumer_secret,
  :endpoint,
  :oauth_token,
  :oauth_token_secret,
  :blog_host,
  :debug
].freeze
DEFAULT_CONSUMER_KEY =

By default, don’t set an application key

nil
DEFAULT_CONSUMER_SECRET =

By default, don’t set an application secret

nil
DEFAULT_ENDPOINT =

The endpoint that will be used to connect if none is set

'http://api.tumblr.com/v2'.freeze
DEFAULT_OAUTH_TOKEN =

By default, don’t set a user oauth token

nil
DEFAULT_OAUTH_TOKEN_SECRET =

By default, don’t set a user oauth secret

nil
DEFAULT_BLOG_HOST =

By default don’t set blog_host

nil
DEFAULT_DEBUG =

Disable debug output by default

false

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object

When this module is extended, set all configuration options to their default values



39
40
41
# File 'lib/tumblr-oauth/configuration.rb', line 39

def self.extended(base)
  base.reset
end

Instance Method Details

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

Convenience method to allow configuration options to be set in a block

Yields:

  • (_self)

Yield Parameters:



44
45
46
# File 'lib/tumblr-oauth/configuration.rb', line 44

def configure
  yield self
end

#optionsObject

Create a hash of options and their values



49
50
51
# File 'lib/tumblr-oauth/configuration.rb', line 49

def options
  {}.tap{ |options| VALID_OPTIONS_KEYS.each{|k| options[k] = send(k) } }
end

#resetObject

Reset all configuration options to defaults



54
55
56
57
58
59
60
61
62
63
# File 'lib/tumblr-oauth/configuration.rb', line 54

def reset
  self.consumer_key       = DEFAULT_CONSUMER_KEY
  self.consumer_secret    = DEFAULT_CONSUMER_SECRET
  self.endpoint           = DEFAULT_ENDPOINT
  self.oauth_token        = DEFAULT_OAUTH_TOKEN
  self.oauth_token_secret = DEFAULT_OAUTH_TOKEN_SECRET
  self.blog_host          = DEFAULT_BLOG_HOST
  self.debug              = DEFAULT_DEBUG
  self
end