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

Version Path
renalware-core-2.0.0.pre.rc11 app/presenters/renalware/system/users_presenter.rb
renalware-core-2.0.0.pre.rc10 app/presenters/renalware/system/users_presenter.rb
renalware-core-2.0.0.pre.rc9 app/presenters/renalware/system/users_presenter.rb
renalware-core-2.0.0.pre.rc8 app/presenters/renalware/system/users_presenter.rb
renalware-core-2.0.0.pre.rc7 app/presenters/renalware/system/users_presenter.rb
renalware-core-2.0.0.pre.rc6 app/presenters/renalware/system/users_presenter.rb
renalware-core-2.0.0.pre.rc5 app/presenters/renalware/system/users_presenter.rb
renalware-core-2.0.0.pre.rc4 app/presenters/renalware/system/users_presenter.rb
renalware-core-2.0.0.pre.rc3 app/presenters/renalware/system/users_presenter.rb
renalware-core-2.0.0.pre.rc1 app/presenters/renalware/system/users_presenter.rb
renalware-core-2.0.0.pre.beta12 app/presenters/renalware/system/users_presenter.rb