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.42 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.41 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.40 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.39 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.38 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.37 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.36 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.35 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.34 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.33 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.32 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.31 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.30 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.28 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.27 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.26 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.25 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.24 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.23 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.22 app/models/renalware/renal/prd_descriptions/search_query.rb