Sha256: d2f9fccbc14ce25db32de9e9b586feb4d7444cd0d1a6fa3d6c0c64d8a346cacf
Contents?: true
Size: 603 Bytes
Versions: 11
Compression:
Stored size: 603 Bytes
Contents
module Renalware module System class UsersPresenter def list_for_dropdown(user_to_promote_to_top: nil) return users if user_to_promote_to_top.blank? matching_user = users.detect{ |user| user.id == user_to_promote_to_top.id } make_user_first_in_list(matching_user) if matching_user.present? users end private def make_user_first_in_list(user) users.delete(user) users.unshift(user) end def users @users ||= Renalware::User.select(:id, :family_name, :given_name).ordered.to_a end end end end
Version data entries
11 entries across 11 versions & 1 rubygems