Class: SoarEnvironment::Environment

Inherits:
Object
  • Object
show all
Defined in:
lib/soar_environment.rb

Constant Summary collapse

SOAR_CONFIGURATION_KEYS =
['IDENTIFIER', 'CAS_SERVER', 'SESSION_KEY', 'SESSION_SECRET']

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#environmentObject (readonly)

Returns the value of attribute environment.



13
14
15
# File 'lib/soar_environment.rb', line 13

def environment
  @environment
end

#environment_fileObject (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_environmentObject

Raises:

  • (ArgumentError)


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

Raises:

  • (ArgumentError)


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