Class: Flexipass::Configuration

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

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_tokenObject

Returns the value of attribute company_token.



6
7
8
# File 'lib/flexipass/configuration.rb', line 6

def company_token
  @company_token
end

#enable_loggingObject

Returns the value of attribute enable_logging.



6
7
8
# File 'lib/flexipass/configuration.rb', line 6

def enable_logging
  @enable_logging
end

#environmentObject

Returns the value of attribute environment.



6
7
8
# File 'lib/flexipass/configuration.rb', line 6

def environment
  @environment
end

#passwordObject

Returns the value of attribute password.



6
7
8
# File 'lib/flexipass/configuration.rb', line 6

def password
  @password
end

#server_addressObject (readonly)

Returns the value of attribute server_address.



7
8
9
# File 'lib/flexipass/configuration.rb', line 7

def server_address
  @server_address
end

#usernameObject

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.

Raises:



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