Sha256: 7316a99e9579165462b66595c62792175237c59053159834048476bab666a8e4
Contents?: true
Size: 887 Bytes
Versions: 11
Compression:
Stored size: 887 Bytes
Contents
module WithAssignments extend ActiveSupport::Concern # TODO we must avoid _for(user) methods when they # are hidden the assignment object, since an assignment already encapsulates # the exercise-user pair, and many times they impose a performance hit, # since in the normal scenario the assignment object already exists included do has_many :assignments, dependent: :destroy end def messages_for(user) assignment_for(user).messages end def has_messages_for?(user) messages_for(user).present? end def find_assignment_for(user, _organization) assignments.find_by(submitter: user) end def status_for(user) assignment_for(user).status if user end def assignment_for(user, organization: Organization.current) find_assignment_for(user, organization) || user.assignments.build(exercise: self, organization: organization) end end
Version data entries
11 entries across 11 versions & 2 rubygems