Sha256: fbdb3ab2ac1354b0db39f56dde5da472c55508819e83a5da3481f710648e6c05

Contents?: true

Size: 1.32 KB

Versions: 10

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.current_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

10 entries across 10 versions & 1 rubygems

Version Path
meibo-0.27.1 lib/meibo/builder.rb
meibo-0.27.0 lib/meibo/builder.rb
meibo-0.26.0 lib/meibo/builder.rb
meibo-0.25.3 lib/meibo/builder.rb
meibo-0.25.2 lib/meibo/builder.rb
meibo-0.25.1 lib/meibo/builder.rb
meibo-0.25.0 lib/meibo/builder.rb
meibo-0.24.0 lib/meibo/builder.rb
meibo-0.23.0 lib/meibo/builder.rb
meibo-0.22.0 lib/meibo/builder.rb