Sha256: 56898d2eb5d497183616f97fd295f4e1f57116090bf3f74a3e85073c02554936

Contents?: true

Size: 994 Bytes

Versions: 10

Compression:

Stored size: 994 Bytes

Contents

require_dependency "renalware/letters"

module Renalware
  module Letters
    class ListsController < Letters::BaseController
      include Renalware::Concerns::Pageable

      def show
        query = LetterQuery.new(q: params[:q])
        letters = find_and_authorize_letters(query)

        render locals: {
          letters: letters,
          authors: User.author.ordered,
          typists: User.ordered,
          q: query.search
        }
      end

      private

      def find_and_authorize_letters(query)
        collection = call_query(query).page(page).per(per_page)
        present_letters(collection).tap { |letters| authorize letters }
      end

      def present_letters(letters)
        CollectionPresenter.new(letters, LetterPresenterFactory)
      end

      def call_query(query)
        query
          .call
          .with_patient
          .with_main_recipient
          .with_letterhead
          .with_author
          .with_created_by
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
renalware-core-2.0.0.pre.rc11 app/controllers/renalware/letters/lists_controller.rb
renalware-core-2.0.0.pre.rc10 app/controllers/renalware/letters/lists_controller.rb
renalware-core-2.0.0.pre.rc9 app/controllers/renalware/letters/lists_controller.rb
renalware-core-2.0.0.pre.rc8 app/controllers/renalware/letters/lists_controller.rb
renalware-core-2.0.0.pre.rc7 app/controllers/renalware/letters/lists_controller.rb
renalware-core-2.0.0.pre.rc6 app/controllers/renalware/letters/lists_controller.rb
renalware-core-2.0.0.pre.rc5 app/controllers/renalware/letters/lists_controller.rb
renalware-core-2.0.0.pre.rc4 app/controllers/renalware/letters/lists_controller.rb
renalware-core-2.0.0.pre.rc3 app/controllers/renalware/letters/lists_controller.rb
renalware-core-2.0.0.pre.rc1 app/controllers/renalware/letters/lists_controller.rb