class OneRoster::Types::Enrollment

Attributes

classroom_uid[R]
provider[R]
role[R]
uid[R]
user_uid[R]

Public Class Methods

new(attributes = {}, *) click to toggle source
# 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

Public Instance Methods

primary() click to toggle source
# File lib/types/enrollment.rb, line 28
def primary
  teacher? && @primary.to_s == 'true'
end
student?() click to toggle source
# File lib/types/enrollment.rb, line 36
def student?
  @role == 'student'
end
teacher?() click to toggle source
# File lib/types/enrollment.rb, line 32
def teacher?
  @role == 'teacher'
end
to_h() click to toggle source
# File lib/types/enrollment.rb, line 40
def to_h
  {
    classroom_uid: @classroom_uid,
    user_uid: @user_uid,
    primary: primary,
    provider: @provider
  }
end
valid?() click to toggle source
# File lib/types/enrollment.rb, line 22
def valid?
  return true if student?

  teacher?
end