Sha256: 577990fc570dd986590420b1cf6892e7310dc2af33135697961b8a868b2576d2

Contents?: true

Size: 1.3 KB

Versions: 5

Compression:

Stored size: 1.3 KB

Contents

# frozen_string_literal: true

require 'forwardable'

module Meibo
  class Builder
    extend Forwardable

    attr_reader :roster, :profile

    def_delegators :@roster, :academic_sessions, :classes, :courses, :demographics, :enrollments, :organizations, :roles, :users, :user_profiles

    def initialize(roster:, profile: Meibo.default_profile)
      @roster = roster
      @profile = profile
    end

    def build_academic_session(**kw)
      builder_for(:academic_session).new(builder: self, **kw)
    end

    def build_classroom(**kw)
      builder_for(:class).new(builder: self, **kw)
    end

    def build_course(**kw)
      builder_for(:course).new(builder: self, **kw)
    end

    def build_demographic(**kw)
      builder_for(:demographic).new(builder: self, **kw)
    end

    def build_enrollment(**kw)
      builder_for(:enrollment).new(builder: self, **kw)
    end

    def build_organization(**kw)
      builder_for(:org).new(builder: self, **kw)
    end

    def build_role(**kw)
      builder_for(:role).new(builder: self, **kw)
    end

    def build_user(**kw)
      builder_for(:user).new(builder: self, **kw)
    end

    def build_user_profile(**kw)
      builder_for(:user_profile).new(builder: self, **kw)
    end

    private

    def builder_for(key)
      profile.builder_for(key)
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
meibo-0.16.0 lib/meibo/builder.rb
meibo-0.15.0 lib/meibo/builder.rb
meibo-0.14.0 lib/meibo/builder.rb
meibo-0.13.0 lib/meibo/builder.rb
meibo-0.12.0 lib/meibo/builder.rb