Sha256: d3bdea7b77ba46cf4c469e4ef2d30ab469c26162125560dbdbfcfe9395629533

Contents?: true

Size: 1.32 KB

Versions: 5

Compression:

Stored size: 1.32 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.21.0 lib/meibo/builder.rb
meibo-0.20.0 lib/meibo/builder.rb
meibo-0.19.0 lib/meibo/builder.rb
meibo-0.18.0 lib/meibo/builder.rb
meibo-0.17.0 lib/meibo/builder.rb