Class: OneRoster::Types::Enrollment
- Defined in:
- lib/types/enrollment.rb
Instance Attribute Summary collapse
-
#classroom_uid ⇒ Object
readonly
Returns the value of attribute classroom_uid.
-
#provider ⇒ Object
readonly
Returns the value of attribute provider.
-
#role ⇒ Object
readonly
Returns the value of attribute role.
-
#uid ⇒ Object
readonly
Returns the value of attribute uid.
-
#user_uid ⇒ Object
readonly
Returns the value of attribute user_uid.
Instance Method Summary collapse
-
#initialize(attributes = {}) ⇒ Enrollment
constructor
A new instance of Enrollment.
- #primary ⇒ Object
- #student? ⇒ Boolean
- #teacher? ⇒ Boolean
- #to_h ⇒ Object
- #valid? ⇒ Boolean
Constructor Details
#initialize(attributes = {}) ⇒ Enrollment
Returns a new instance of Enrollment.
12 13 14 15 16 17 18 19 20 |
# File 'lib/types/enrollment.rb', line 12 def initialize(attributes = {}, *) @uid = attributes['sourcedId'] # allow instantiation with classroom_uid and user_uid attrs for consistency with clever @classroom_uid = attributes['classroom_uid'] || attributes.dig('class', 'sourcedId') @user_uid = attributes['user_uid'] || attributes.dig('user', 'sourcedId') @role = attributes['role'] @primary = attributes['primary'] @provider = 'oneroster' end |
Instance Attribute Details
#classroom_uid ⇒ Object (readonly)
Returns the value of attribute classroom_uid.
6 7 8 |
# File 'lib/types/enrollment.rb', line 6 def classroom_uid @classroom_uid end |
#provider ⇒ Object (readonly)
Returns the value of attribute provider.
6 7 8 |
# File 'lib/types/enrollment.rb', line 6 def provider @provider end |
#role ⇒ Object (readonly)
Returns the value of attribute role.
6 7 8 |
# File 'lib/types/enrollment.rb', line 6 def role @role end |
#uid ⇒ Object (readonly)
Returns the value of attribute uid.
6 7 8 |
# File 'lib/types/enrollment.rb', line 6 def uid @uid end |
#user_uid ⇒ Object (readonly)
Returns the value of attribute user_uid.
6 7 8 |
# File 'lib/types/enrollment.rb', line 6 def user_uid @user_uid end |
Instance Method Details
#primary ⇒ Object
28 29 30 |
# File 'lib/types/enrollment.rb', line 28 def primary teacher? && @primary.to_s == 'true' end |
#student? ⇒ Boolean
36 37 38 |
# File 'lib/types/enrollment.rb', line 36 def student? @role == 'student' end |
#teacher? ⇒ Boolean
32 33 34 |
# File 'lib/types/enrollment.rb', line 32 def teacher? @role == 'teacher' end |
#to_h ⇒ Object
40 41 42 43 44 45 46 47 |
# File 'lib/types/enrollment.rb', line 40 def to_h { classroom_uid: @classroom_uid, user_uid: @user_uid, primary: primary, provider: @provider } end |
#valid? ⇒ Boolean
22 23 24 25 26 |
# File 'lib/types/enrollment.rb', line 22 def valid? return true if student? teacher? end |