Sha256: f9e5a7f1c1f250ba1f847f83f91fe2e38a3df4cf2d36862c26036e733d2c1a48

Contents?: true

Size: 695 Bytes

Versions: 46

Compression:

Stored size: 695 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.ransack(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

46 entries across 46 versions & 1 rubygems

Version Path
renalware-core-2.0.92 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.91 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.90 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.89 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.88 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.87 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.86 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.85 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.84 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.83 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.82 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.81 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.80 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.79 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.78 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.77 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.76 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.75 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.74 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.73 app/models/renalware/renal/prd_descriptions/search_query.rb