Class: ScormEngine::Models::Dispatch
- Inherits:
-
Object
- Object
- ScormEngine::Models::Dispatch
- Defined in:
- lib/scorm_engine/models/dispatch.rb
Instance Attribute Summary collapse
-
#allow_new_registrations ⇒ Object
TODO: Not sure we want this to be settable.
-
#course_id ⇒ Object
TODO: Not sure we want this to be settable.
-
#destination_id ⇒ Object
TODO: Not sure we want this to be settable.
-
#expiration_date ⇒ Object
TODO: Not sure we want this to be settable.
-
#external_config ⇒ Object
TODO: Not sure we want this to be settable.
-
#id ⇒ Object
TODO: Not sure we want this to be settable.
-
#instanced ⇒ Object
TODO: Not sure we want this to be settable.
-
#options ⇒ Object
writeonly
Sets the attribute options.
-
#registration_cap ⇒ Object
TODO: Not sure we want this to be settable.
Class Method Summary collapse
-
.get_expiration_date(options = {}) ⇒ Time
Extract and normalize the expiration date from the API options.
- .new_from_api(options = {}) ⇒ Object
Instance Attribute Details
#allow_new_registrations ⇒ Object
TODO: Not sure we want this to be settable. Will depend on how we go about creating/updating records. For now it makes it easier to create instances from API options hash.
12 13 14 |
# File 'lib/scorm_engine/models/dispatch.rb', line 12 def allow_new_registrations @allow_new_registrations end |
#course_id ⇒ Object
TODO: Not sure we want this to be settable. Will depend on how we go about creating/updating records. For now it makes it easier to create instances from API options hash.
12 13 14 |
# File 'lib/scorm_engine/models/dispatch.rb', line 12 def course_id @course_id end |
#destination_id ⇒ Object
TODO: Not sure we want this to be settable. Will depend on how we go about creating/updating records. For now it makes it easier to create instances from API options hash.
12 13 14 |
# File 'lib/scorm_engine/models/dispatch.rb', line 12 def destination_id @destination_id end |
#expiration_date ⇒ Object
TODO: Not sure we want this to be settable. Will depend on how we go about creating/updating records. For now it makes it easier to create instances from API options hash.
12 13 14 |
# File 'lib/scorm_engine/models/dispatch.rb', line 12 def expiration_date @expiration_date end |
#external_config ⇒ Object
TODO: Not sure we want this to be settable. Will depend on how we go about creating/updating records. For now it makes it easier to create instances from API options hash.
12 13 14 |
# File 'lib/scorm_engine/models/dispatch.rb', line 12 def external_config @external_config end |
#id ⇒ Object
TODO: Not sure we want this to be settable. Will depend on how we go about creating/updating records. For now it makes it easier to create instances from API options hash.
12 13 14 |
# File 'lib/scorm_engine/models/dispatch.rb', line 12 def id @id end |
#instanced ⇒ Object
TODO: Not sure we want this to be settable. Will depend on how we go about creating/updating records. For now it makes it easier to create instances from API options hash.
12 13 14 |
# File 'lib/scorm_engine/models/dispatch.rb', line 12 def instanced @instanced end |
#options=(value) ⇒ Object
Sets the attribute options
6 7 8 |
# File 'lib/scorm_engine/models/dispatch.rb', line 6 def (value) @options = value end |
#registration_cap ⇒ Object
TODO: Not sure we want this to be settable. Will depend on how we go about creating/updating records. For now it makes it easier to create instances from API options hash.
12 13 14 |
# File 'lib/scorm_engine/models/dispatch.rb', line 12 def registration_cap @registration_cap end |
Class Method Details
.get_expiration_date(options = {}) ⇒ Time
Extract and normalize the expiration date from the API options.
44 45 46 47 48 |
# File 'lib/scorm_engine/models/dispatch.rb', line 44 def self.get_expiration_date( = {}) expiration_date = ["expirationDate"] return if expiration_date.nil? || expiration_date == "none" Time.parse(expiration_date) end |
.new_from_api(options = {}) ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/scorm_engine/models/dispatch.rb', line 15 def self.new_from_api( = {}) this = new this. = .dup this.id = ["id"] # get_dispatches (plural) returns values in a nested 'data' field. # get_dispatches (singular) does not. data = ["data"] || this.destination_id = data["destinationId"] this.course_id = data["courseId"] this.allow_new_registrations = data["allowNewRegistrations"] this.instanced = data["instanced"] this.registration_cap = data["registrationCap"]&.to_i this.expiration_date = get_expiration_date(data) this.external_config = data["externalConfig"] this end |