Sha256: a850b312cabe6ef5cf0e714b243c1d10b3c48061cdc76a441067403a1dfe996b

Contents?: true

Size: 1.21 KB

Versions: 12

Compression:

Stored size: 1.21 KB

Contents

# frozen_string_literal: true

module Meibo
  class JapanProfile < ::Meibo::Profile
    class Enrollment < ::Meibo::Enrollment
      ROLES = {
        student: 'student',
        teacher: 'teacher',
        administrator: 'administrator',
        guardian: 'guardian'
      }.freeze

      DataModel.define(
        self,
          attribute_name_to_header_field_map: superclass.attribute_name_to_header_field_map.merge(
          shusseki_no: 'metadata.jp.ShussekiNo',
          public_flg: 'metadata.jp.PublicFlg'
        ).freeze,
        converters: superclass.converters.merge(
          boolean: [*superclass.converters[:boolean], :public_flg].freeze,
          enum: { role: ROLES.values.freeze }.freeze,
          integer: [:shusseki_no].freeze
        ).freeze
      )

      # NOTE: 児童生徒の場合primaryはfalse固定
      # MEMO: 保護者の場合もそうでは?
      def initialize(shusseki_no: nil, public_flg: nil, role:, primary: (role == ROLES[:student] ? false : nil), **other_fields)
        super(role: role, primary: primary, **other_fields)
        @shusseki_no = shusseki_no
        @public_flg = public_flg
      end

      def guardian?
        role == ROLES[:guardian]
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
meibo-0.16.0 lib/meibo/japan_profile/enrollment.rb
meibo-0.15.0 lib/meibo/japan_profile/enrollment.rb
meibo-0.14.0 lib/meibo/japan_profile/enrollment.rb
meibo-0.13.0 lib/meibo/japan_profile/enrollment.rb
meibo-0.12.0 lib/meibo/japan_profile/enrollment.rb
meibo-0.11.0 lib/meibo/japan_profile/enrollment.rb
meibo-0.10.0 lib/meibo/japan_profile/enrollment.rb
meibo-0.9.0 lib/meibo/japan_profile/enrollment.rb
meibo-0.8.0 lib/meibo/japan_profile/enrollment.rb
meibo-0.7.0 lib/meibo/japan_profile/enrollment.rb
meibo-0.6.0 lib/meibo/japan_profile/enrollment.rb
meibo-0.5.0 lib/meibo/japan_profile/enrollment.rb