Sha256: 67879b2e6d803f278cf1bb4a34b96f75f5c1371a89942c9e97c78514dcae808d

Contents?: true

Size: 827 Bytes

Versions: 3

Compression:

Stored size: 827 Bytes

Contents

# frozen_string_literal: true

module Meibo
  class EnrollmentSet < DataSet
    def check_semantically_consistent
      super

      each do |enrollment|
        roster.classes.find(enrollment.class_sourced_id)
        school = roster.organizations.find(enrollment.school_sourced_id)
        raise InvalidDataTypeError unless school.school?

        roster.users.find(enrollment.user_sourced_id)
        raise InvalidDataTypeError if enrollment.primary && !enrollment.teacher?
      end
    end

    def administrator
      @cache[:administrator] ||= new(select(&:administrator?))
    end

    def proctor
      @cache[:proctor] ||= new(select(&:proctor?))
    end

    def student
      @cache[:student] ||= new(select(&:student?))
    end

    def teacher
      @cache[:teacher] ||= new(select(&:teacher?))
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
meibo-0.27.1 lib/meibo/enrollment_set.rb
meibo-0.27.0 lib/meibo/enrollment_set.rb
meibo-0.26.0 lib/meibo/enrollment_set.rb