Class: ActiveLrs::Configuration
- Inherits:
-
Object
- Object
- ActiveLrs::Configuration
- Defined in:
- lib/active_lrs/configuration.rb
Overview
Stores configuration for xAPI/LRS interactions.
This includes the xAPI profile server URL, default locale, and remote LRS instances loaded from a YAML configuration file.
Instance Attribute Summary collapse
-
#default_locale ⇒ String
Default locale to use for xAPI statements (default: “en-US”).
-
#remote_lrs_instances ⇒ Array<Hash>
List of remote LRS endpoints loaded from config/remote_lrs.yml.
-
#xapi_profile_server_url ⇒ String
The URL of the xAPI profile server (default: “profiles.adlnet.gov/”).
Instance Method Summary collapse
-
#initialize(env: ENV["RAILS_ENV"] || "development") ⇒ void
constructor
Initializes a new Configuration instance.
Constructor Details
#initialize(env: ENV["RAILS_ENV"] || "development") ⇒ void
Initializes a new Configuration instance.
Loads the remote LRS endpoints from config/remote_lrs.yml if it exists. If the file or the environment-specific section is missing, defaults to an empty array.
25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/active_lrs/configuration.rb', line 25 def initialize(env: ENV["RAILS_ENV"] || "development") @xapi_profile_server_url = "https://profiles.adlnet.gov/" @default_locale = "en-US" path = File.join(Dir.pwd, "config", "remote_lrs.yml") if File.exist?(path) raw = ERB.new(File.read(path)).result yaml = YAML.safe_load(raw, aliases: true) env_config = yaml.fetch(env, {}) @remote_lrs_instances = env_config["endpoints"] || [] else @remote_lrs_instances = [] end end |
Instance Attribute Details
#default_locale ⇒ String
Returns Default locale to use for xAPI statements (default: “en-US”).
11 12 13 |
# File 'lib/active_lrs/configuration.rb', line 11 def default_locale @default_locale end |
#remote_lrs_instances ⇒ Array<Hash>
Returns List of remote LRS endpoints loaded from config/remote_lrs.yml.
14 15 16 |
# File 'lib/active_lrs/configuration.rb', line 14 def remote_lrs_instances @remote_lrs_instances end |
#xapi_profile_server_url ⇒ String
Returns The URL of the xAPI profile server (default: “profiles.adlnet.gov/”).
8 9 10 |
# File 'lib/active_lrs/configuration.rb', line 8 def xapi_profile_server_url @xapi_profile_server_url end |