Sha256: 7738514d28fa10c6b520413e60231203a6b13f4193f337c70b932b526ed25f20

Contents?: true

Size: 677 Bytes

Versions: 3

Compression:

Stored size: 677 Bytes

Contents

# frozen_string_literal: true

require_dependency "renalware/letters"

module Renalware
  module Letters
    module QueryableLetter
      def finder_needs_type_condition?
        false
      end

      def ransackable_scopes(_auth_object = nil)
        %i(state_eq)
      end

      def state_eq(state = :draft)
        where(type: Letter.state_class_name(state))
      end
    end

    class LetterQuery
      def initialize(q: nil)
        @q = q || {}
        @q[:s] ||= ["updated_at desc"]
      end

      def call
        search.result
      end

      def search
        @search ||= Letter.extend(QueryableLetter).includes(:event).search(@q)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
renalware-core-2.0.35 app/models/renalware/letters/letter_query.rb
renalware-core-2.0.34 app/models/renalware/letters/letter_query.rb
renalware-core-2.0.33 app/models/renalware/letters/letter_query.rb