Class: SoarEnvironment::Environment
- Inherits:
-
Object
- Object
- SoarEnvironment::Environment
- Defined in:
- lib/soar_environment.rb
Constant Summary collapse
- SOAR_CONFIGURATION_KEYS =
['IDENTIFIER', 'CAS_SERVER', 'SESSION_KEY', 'SESSION_SECRET']
Instance Attribute Summary collapse
-
#environment ⇒ Object
readonly
Returns the value of attribute environment.
-
#environment_file ⇒ Object
readonly
Returns the value of attribute environment_file.
Instance Method Summary collapse
-
#initialize(environment_file = nil) ⇒ Environment
constructor
A new instance of Environment.
- #load_environment ⇒ Object
- #supplement_with_configuration(configuration, keys = SOAR_CONFIGURATION_KEYS) ⇒ Object
Constructor Details
#initialize(environment_file = nil) ⇒ Environment
Returns a new instance of Environment.
15 16 17 |
# File 'lib/soar_environment.rb', line 15 def initialize(environment_file = nil) @environment_file = environment_file end |
Instance Attribute Details
#environment ⇒ Object (readonly)
Returns the value of attribute environment.
13 14 15 |
# File 'lib/soar_environment.rb', line 13 def environment @environment end |
#environment_file ⇒ Object (readonly)
Returns the value of attribute environment_file.
12 13 14 |
# File 'lib/soar_environment.rb', line 12 def environment_file @environment_file end |
Instance Method Details
#load_environment ⇒ Object
19 20 21 22 23 |
# File 'lib/soar_environment.rb', line 19 def load_environment @environment = merge(load_file(@environment_file), load_env) raise ArgumentError.new("RACK_ENV not set in environment nor in properties or configuration") if (@environment['RACK_ENV'].nil?) or (@environment['RACK_ENV'].strip == "") @environment end |
#supplement_with_configuration(configuration, keys = SOAR_CONFIGURATION_KEYS) ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/soar_environment.rb', line 25 def supplement_with_configuration(configuration, keys = SOAR_CONFIGURATION_KEYS) raise ArgumentError.new("configuration not provided") if (configuration.nil?) raise ArgumentError.new("configuration not valid") if not (configuration.is_a?(Hash)) keys.each do |key| @environment[key] ||= configuration[key] end @environment end |