Class: ScormEngine::Models::CourseConfiguration
- Defined in:
- lib/scorm_engine/models/course_configuration.rb
Instance Attribute Summary collapse
Class Method Summary collapse
-
.get_settings_from_api(options = {}) ⇒ Hash
Extract and normalize the settings from the API options.
- .new_from_api(options = {}) ⇒ Object
Methods inherited from Base
Instance Attribute Details
#settings ⇒ Hash
7 8 9 |
# File 'lib/scorm_engine/models/course_configuration.rb', line 7 def settings @settings end |
Class Method Details
.get_settings_from_api(options = {}) ⇒ Hash
Extract and normalize the settings from the API options.
26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/scorm_engine/models/course_configuration.rb', line 26 def self.get_settings_from_api( = {}) return {} if .nil? # API v2 uses "settingItems", API v1 uses "configurationItems" configuration_items = ["settingItems"] || ["configurationItems"] return {} unless configuration_items.respond_to?(:reduce) configuration_items.reduce({}) do |m, o| # API v2 uses "effectiveValue", API v1 uses "value" value = o["effectiveValue"] || o["value"] m[o["id"]] = value m end end |
.new_from_api(options = {}) ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/scorm_engine/models/course_configuration.rb', line 9 def self.new_from_api( = {}) this = new this. = .dup this.settings = get_settings_from_api() this end |