module GrowlCar::Configuration

Attributes

password[W]
username[W]

Public Class Methods

boxcar_url() click to toggle source

Url for boxcar.io

@return [String]

# File lib/growl_car/configuration.rb, line 20
def boxcar_url
  "https://boxcar.io/notifications"
end
keys() click to toggle source

List of keys used for configuration

@return [Array]

# File lib/growl_car/configuration.rb, line 10
def keys
  @keys ||= [
    :username,
    :password
  ]
end

Public Instance Methods

configure() { |self| ... } click to toggle source

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

@raise [GrowlCar::Error::ConfigurationError] if credentials are not in the form of a string

# File lib/growl_car/configuration.rb, line 28
def configure
  yield self
  validate_credentials!
  self
end
reset!() click to toggle source

Set all configuration values to nil

# File lib/growl_car/configuration.rb, line 35
def reset!
  GrowlCar::Configuration.keys.each do |key|
    instance_variable_set(:"@#{key}", nil)
  end
end

Private Instance Methods

credentials() click to toggle source
# File lib/growl_car/configuration.rb, line 43
def credentials
  {
    :username => @username,
    :password => @password
  }
end
validate_credentials!() click to toggle source
# File lib/growl_car/configuration.rb, line 50
def validate_credentials!
  credentials.each do |credential, value|
    unless value.is_a?(String)
      raise GrowlCar::Error::ConfigurationError, "Invalid #{credential}. Must be a string"
    end
  end
end