Files
codeocean/app/models/concerns/contributor_creation.rb
Sebastian Serth dab8f777b3 Extract Contributor concern as abstract class
During documentation of the pair programming feature, we noticed that the Contributor should be an abstract class, which is parent for the User and the ProgrammingGroup. With this commit, we perform these changes.
2024-04-02 16:56:49 +02:00

18 lines
477 B
Ruby

# frozen_string_literal: true
module ContributorCreation
extend ActiveSupport::Concern
ALLOWED_CONTRIBUTOR_TYPES = [InternalUser, ExternalUser, ProgrammingGroup].map(&:to_s).freeze
included do
belongs_to :contributor, polymorphic: true
alias_method :user, :contributor
alias_method :user=, :contributor=
alias_method :author, :user
alias_method :creator, :user
validates :contributor_type, inclusion: {in: ALLOWED_CONTRIBUTOR_TYPES}
end
end