Sha256: 7498892a50f463d955b3e9a411a226bbdeb47052bfca306b06ebf23d2b78fc35

Contents?: true

Size: 694 Bytes

Versions: 51

Compression:

Stored size: 694 Bytes

Contents

# frozen_string_literal: true

require_dependency "renalware/renal"

module Renalware
  module Renal
    module PRDDescriptions
      class SearchQuery
        attr_reader :term, :page, :per_page

        def initialize(term:, page: 1, per_page: 50)
          @term = term
          @page = page
          @per_page = per_page
        end

        def call
          search.result.page(page).per(per_page).select(fields)
        end

        private

        def search
          @search ||= PRDDescription.search(term_or_code_cont: term).tap do |s|
            s.sorts = ["term"]
          end
        end

        def fields
          %i(id code term)
        end
      end
    end
  end
end

Version data entries

51 entries across 51 versions & 1 rubygems

Version Path
renalware-core-2.0.64 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.63 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.62 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.61 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.60 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.58 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.57 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.56 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.55 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.54 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.53 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.52 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.51 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.50 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.48 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.47 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.46 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.45 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.44 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.43 app/models/renalware/renal/prd_descriptions/search_query.rb