Module: Tweetsentiments::Configuration

Included in:
Tweetsentiments
Defined in:
lib/tweetsentiments/configuration.rb

Constant Summary collapse

VALID_OPTIONS_KEYS =
[:endpoint, :format, :user_agent, :proxy, :adapter].freeze
VALID_FORMATS =
[:json, :xml].freeze
DEFAULT_FORMAT =
:json.freeze
DEFAULT_ENDPOINT =
'http://api.tweetsentiments.com:8080/api/'.freeze
DEFAULT_USER_AGENT =
"Tweetsentiments Ruby Gem #{Tweetsentiments::VERSION}".freeze
DEFAULT_PROXY =
nil.freeze
DEFAULT_ADAPTER =
Faraday.default_adapter.freeze

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.extended(base) ⇒ Object



15
16
17
# File 'lib/tweetsentiments/configuration.rb', line 15

def self.extended(base)
  base.reset
end

Instance Method Details

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

Yields:

  • (_self)

Yield Parameters:



19
20
21
# File 'lib/tweetsentiments/configuration.rb', line 19

def configure
  yield self
end

#optionsObject



23
24
25
26
27
# File 'lib/tweetsentiments/configuration.rb', line 23

def options
  VALID_OPTIONS_KEYS.inject({}) do |option, key|
    option.merge!(key => send(key))
  end
end

#resetObject



29
30
31
32
33
34
35
# File 'lib/tweetsentiments/configuration.rb', line 29

def reset
  self.endpoint = DEFAULT_ENDPOINT
  self.format = DEFAULT_FORMAT
  self.user_agent = DEFAULT_USER_AGENT
  self.proxy = DEFAULT_PROXY
  self.adapter = DEFAULT_ADAPTER
end