module EmpireAvenue::Configurable
Attributes
client_id[RW]
client_secret[RW]
connection_options[RW]
endpoint[RW]
identity_map[RW]
middleware[RW]
oauth_token[RW]
oauth_token_secret[RW]
Public Class Methods
keys()
click to toggle source
# File lib/empireavenue/configurable.rb, line 13 def keys @keys ||= [ :client_id, :client_secret, :oauth_token, :oauth_token_secret, :endpoint, :connection_options, :identity_map, :middleware, ] end
Public Instance Methods
configure() { |self| ... }
click to toggle source
Convenience method to allow configuration options to be set in a block
@raise [EmpireAvenue::Error::ConfigurationError] Error
is raised when supplied
empire avenue credentials are not a String or Symbol.
# File lib/empireavenue/configurable.rb, line 32 def configure yield self validate_credential_type! self end
credentials?()
click to toggle source
@return [Boolean]
# File lib/empireavenue/configurable.rb, line 39 def credentials? credentials.values.all? end
reset!()
click to toggle source
# File lib/empireavenue/configurable.rb, line 43 def reset! EmpireAvenue::Configurable.keys.each do |key| instance_variable_set(:"@#{key}", EmpireAvenue::Default.options[key]) end self end
Also aliased as: setup
Private Instance Methods
credentials()
click to toggle source
@return [Hash]
# File lib/empireavenue/configurable.rb, line 54 def credentials { :client_id => @client_id, :client_secret => @client_secret, :token => @oauth_token, :token_secret => @oauth_token_secret, } end
options()
click to toggle source
@return [Hash]
# File lib/empireavenue/configurable.rb, line 64 def options Hash[EmpireAvenue::Configurable.keys.map{|key| [key, instance_variable_get(:"@#{key}")]}] end
validate_credential_type!()
click to toggle source
Ensures that all credentials set during configuration are of a valid type. Valid types are String and Symbol.
@raise [EmpireAvenue::Error::ConfigurationError] Error
is raised when
supplied empire avenue credentials are not a String or Symbol.
# File lib/empireavenue/configurable.rb, line 73 def validate_credential_type! credentials.each do |credential, value| next if value.nil? unless value.is_a?(String) || value.is_a?(Symbol) raise(Error::ConfigurationError, "Invalid #{credential} specified: #{value} must be a string or symbol.") end end end