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.21 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.20 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.18 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.17 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.16 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.15 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.14 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.13 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.12 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.11 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.9 app/models/renalware/renal/prd_descriptions/search_query.rb