module Base::EmployeeAdditionalField
  extend ActiveSupport::Concern

  included do
    self.table_name = 'UserStatistics'
    self.primary_key = 'USID'

    alias_attribute :id, :USID
    alias_attribute :school_id, :SchoolID
    alias_attribute :group_id, :USGID
    alias_attribute :order, :Sequence
    alias_attribute :type, :Type
    alias_attribute :name, :Name
    alias_attribute :description, :Description
    alias_attribute :public, :Public
    alias_attribute :validation_type, :ValidationType
    alias_attribute :validation_pattern, :ValidationPattern
    alias_attribute :required, :Required

    before_create :set_defaults

    private
      def set_defaults
        self.validation_pattern = '' unless validation_pattern
      end
  end
end
