Class: Flexipass::Configuration
- Inherits:
-
Object
- Object
- Flexipass::Configuration
- Defined in:
- lib/flexipass/configuration.rb
Overview
The ‘Flexipass` module provides configuration options for the Flexipass gem.
Constant Summary collapse
- DEV_SERVER =
'https://dev.flexipass.it'
- PROD_SERVER =
'https://flexipass.it'
Instance Attribute Summary collapse
-
#company_token ⇒ Object
Returns the value of attribute company_token.
-
#enable_logging ⇒ Object
Returns the value of attribute enable_logging.
-
#environment ⇒ Object
Returns the value of attribute environment.
-
#password ⇒ Object
Returns the value of attribute password.
-
#server_address ⇒ Object
readonly
Returns the value of attribute server_address.
-
#username ⇒ Object
Returns the value of attribute username.
Instance Method Summary collapse
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
-
#validate! ⇒ Object
Validates the configuration options.
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
12 13 14 15 |
# File 'lib/flexipass/configuration.rb', line 12 def initialize @environment = :development set_server_address end |
Instance Attribute Details
#company_token ⇒ Object
Returns the value of attribute company_token.
6 7 8 |
# File 'lib/flexipass/configuration.rb', line 6 def company_token @company_token end |
#enable_logging ⇒ Object
Returns the value of attribute enable_logging.
6 7 8 |
# File 'lib/flexipass/configuration.rb', line 6 def enable_logging @enable_logging end |
#environment ⇒ Object
Returns the value of attribute environment.
6 7 8 |
# File 'lib/flexipass/configuration.rb', line 6 def environment @environment end |
#password ⇒ Object
Returns the value of attribute password.
6 7 8 |
# File 'lib/flexipass/configuration.rb', line 6 def password @password end |
#server_address ⇒ Object (readonly)
Returns the value of attribute server_address.
7 8 9 |
# File 'lib/flexipass/configuration.rb', line 7 def server_address @server_address end |
#username ⇒ Object
Returns the value of attribute username.
6 7 8 |
# File 'lib/flexipass/configuration.rb', line 6 def username @username end |
Instance Method Details
#validate! ⇒ Object
Validates the configuration options. Raises a ‘ConfigurationError` if any required options are missing or if the environment is invalid.
24 25 26 27 28 29 |
# File 'lib/flexipass/configuration.rb', line 24 def validate! raise ConfigurationError, 'Username must be set' if @username.nil? raise ConfigurationError, 'Password must be set' if @password.nil? raise ConfigurationError, 'Company token must be set' if @company_token.nil? raise ConfigurationError, "Invalid environment: #{@environment}. Must be :development or :production" unless [:development, :production].include?(@environment) end |