Sha256: 8181ccac5b3cc8fc17f18893ed4877358c077ed038b89ad357901e27a41f1ff6

Contents?: true

Size: 1.37 KB

Versions: 7

Compression:

Stored size: 1.37 KB

Contents

# frozen_string_literal: true

module Meibo
  module JapanProfile
    class User < ::Meibo::User
      module ClassMethods
        def define_additional_definition(klass)
          DataModel.define(
            klass,
            attribute_name_to_header_field_map: klass.superclass.attribute_name_to_header_field_map.merge(
              kana_given_name: "metadata.jp.kanaGivenName",
              kana_family_name: "metadata.jp.kanaFamilyName",
              kana_middle_name: "metadata.jp.kanaMiddleName",
              home_class: "metadata.jp.homeClass"
            ).freeze,
            converters: klass.superclass.converters
          )
        end
      end

      module InstanceMethods
        # NOTE: enabled_userは必須ではないが固定
        def initialize(enabled_user: true, kana_given_name: nil, kana_family_name: nil, kana_middle_name: nil,
                       home_class: nil, **other_fields)
          super(enabled_user: enabled_user, **other_fields)
          @kana_given_name = kana_given_name
          @kana_family_name = kana_family_name
          @kana_middle_name = kana_middle_name
          @home_class = home_class
        end

        def home_classroom
          home_class && Meibo.current_roster.classes.find(home_class)
        end
      end

      include InstanceMethods
      extend ClassMethods

      define_additional_definition(self)
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
meibo-0.25.3 lib/meibo/japan_profile/user.rb
meibo-0.25.2 lib/meibo/japan_profile/user.rb
meibo-0.25.1 lib/meibo/japan_profile/user.rb
meibo-0.25.0 lib/meibo/japan_profile/user.rb
meibo-0.24.0 lib/meibo/japan_profile/user.rb
meibo-0.23.0 lib/meibo/japan_profile/user.rb
meibo-0.22.0 lib/meibo/japan_profile/user.rb