Class: Meibo::Enrollment
- Inherits:
-
Object
- Object
- Meibo::Enrollment
- Defined in:
- lib/meibo/enrollment.rb
Direct Known Subclasses
Constant Summary collapse
- ROLES =
{ administrator: "administrator", proctor: "proctor", student: "student", teacher: "teacher" }.freeze
Instance Method Summary collapse
- #administrator? ⇒ Boolean
- #classroom ⇒ Object
- #collection ⇒ Object
-
#initialize(sourced_id:, class_sourced_id:, school_sourced_id:, user_sourced_id:, role:, status: nil, date_last_modified: nil, primary: nil, begin_date: nil, end_date: nil, **extension_fields) ⇒ Enrollment
constructor
A new instance of Enrollment.
- #proctor? ⇒ Boolean
- #school ⇒ Object
- #student? ⇒ Boolean
- #teacher? ⇒ Boolean
- #user ⇒ Object
Constructor Details
#initialize(sourced_id:, class_sourced_id:, school_sourced_id:, user_sourced_id:, role:, status: nil, date_last_modified: nil, primary: nil, begin_date: nil, end_date: nil, **extension_fields) ⇒ Enrollment
Returns a new instance of Enrollment.
36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'lib/meibo/enrollment.rb', line 36 def initialize(sourced_id:, class_sourced_id:, school_sourced_id:, user_sourced_id:, role:, status: nil, date_last_modified: nil, primary: nil, begin_date: nil, end_date: nil, **extension_fields) @sourced_id = sourced_id @status = status @date_last_modified = date_last_modified @primary = primary @class_sourced_id = class_sourced_id @school_sourced_id = school_sourced_id @user_sourced_id = user_sourced_id @role = role @begin_date = begin_date @end_date = end_date @extension_fields = extension_fields end |
Instance Method Details
#administrator? ⇒ Boolean
55 56 57 |
# File 'lib/meibo/enrollment.rb', line 55 def administrator? role == ROLES[:administrator] end |
#classroom ⇒ Object
71 72 73 |
# File 'lib/meibo/enrollment.rb', line 71 def classroom Meibo.current_roster.classes.find(class_sourced_id) end |
#collection ⇒ Object
51 52 53 |
# File 'lib/meibo/enrollment.rb', line 51 def collection Meibo.current_roster.enrollments end |
#proctor? ⇒ Boolean
59 60 61 |
# File 'lib/meibo/enrollment.rb', line 59 def proctor? role == ROLES[:proctor] end |
#school ⇒ Object
75 76 77 |
# File 'lib/meibo/enrollment.rb', line 75 def school Meibo.current_roster.organizations.find(school_sourced_id) end |
#student? ⇒ Boolean
63 64 65 |
# File 'lib/meibo/enrollment.rb', line 63 def student? role == ROLES[:student] end |
#teacher? ⇒ Boolean
67 68 69 |
# File 'lib/meibo/enrollment.rb', line 67 def teacher? role == ROLES[:teacher] end |
#user ⇒ Object
79 80 81 |
# File 'lib/meibo/enrollment.rb', line 79 def user Meibo.current_roster.users.find(user_sourced_id) end |