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.113 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.112 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.111 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.110 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.109 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.108 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.106 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.105 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.104 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.103 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.102 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.101 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.100 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.99 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.98 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.97 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.96 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.95 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.94 app/models/renalware/renal/prd_descriptions/search_query.rb
renalware-core-2.0.93 app/models/renalware/renal/prd_descriptions/search_query.rb