Sha256: 4c001492306e131bd54460fcb32d08031f2ca8fe6385c090ea318c85c28a2b1b
Contents?: true
Size: 587 Bytes
Versions: 49
Compression:
Stored size: 587 Bytes
Contents
class TicketAssignment attr_reader :assigned_ids, :unassigned_ids def initialize ticket, user_ids @ticket = ticket @user_ids = user_ids.split(",") end def assign! ids = @user_ids existing_ids = @ticket.assignments.map(&:user_id) @unassigned_ids = existing_ids - ids if @unassigned_ids.any? @ticket.assignments.where(user_id: @unassigned_ids).destroy_all end @assigned_ids = ids - existing_ids @assigned_ids.each do |id| @ticket.assignments.create(user_id: id) end @assigned_ids.any? || @unassigned_ids.any? end end
Version data entries
49 entries across 49 versions & 1 rubygems