Class: Yelp::Configuration
- Inherits:
-
Object
- Object
- Yelp::Configuration
- Defined in:
- lib/yelp/configuration.rb
Constant Summary collapse
- AUTH_KEYS =
[:consumer_key, :consumer_secret, :token, :token_secret]
Instance Method Summary collapse
-
#auth_keys ⇒ Object
Returns a hash of api keys and their values.
-
#initialize(config_hash = nil) ⇒ Configuration
constructor
Creates the configuration.
- #valid? ⇒ Boolean
Constructor Details
#initialize(config_hash = nil) ⇒ Configuration
Creates the configuration
11 12 13 14 15 16 17 |
# File 'lib/yelp/configuration.rb', line 11 def initialize(config_hash = nil) if config_hash.is_a?(Hash) config_hash.each do |config_name, config_value| self.send("#{config_name}=", config_value) end end end |
Instance Method Details
#auth_keys ⇒ Object
Returns a hash of api keys and their values
20 21 22 23 24 25 |
# File 'lib/yelp/configuration.rb', line 20 def auth_keys AUTH_KEYS.inject({}) do |keys_hash, key| keys_hash[key] = send(key) keys_hash end end |
#valid? ⇒ Boolean
27 28 29 |
# File 'lib/yelp/configuration.rb', line 27 def valid? AUTH_KEYS.none?{ |key| send(key).nil? || send(key).empty? } end |