class Pricefinder::Configuration

Constants

AUTH_PARAMS
CONFIG_PARAMS
TOKEN_PARAMS

Public Class Methods

new(config_hash = nil) click to toggle source

Creates the configuration @param [Hash] hash containing configuration params and their values @return [Configuration] a new configuration with the values from the config_params set

# File lib/pricefinder/configuration.rb, line 15
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

Public Instance Methods

config_params() click to toggle source

Returns a hash of config params and their values

# File lib/pricefinder/configuration.rb, line 24
def config_params
  CONFIG_PARAMS.inject({}) do |keys_hash, key|
    keys_hash[key] = send(key)
    keys_hash
  end
end
valid?() click to toggle source

Check that we have all the required params

# File lib/pricefinder/configuration.rb, line 32
def valid?
  TOKEN_PARAMS.none? { |key| send(key).nil? || send(key).empty? } ||
  AUTH_PARAMS.none? { |key| send(key).nil? || send(key).empty? }
end