Class: Renalware::Transplants::LiveDonorsQuery

Inherits:
Object
  • Object
show all
Includes:
ModalityScopes
Defined in:
app/models/renalware/transplants/live_donors_query.rb

Constant Summary collapse

DEFAULT_ORDER =
%w(family_name given_name).freeze

Instance Method Summary collapse

Methods included from ModalityScopes

#with_current_modality_matching, #with_current_modality_of_class

Constructor Details

#initialize(q = {}) ⇒ LiveDonorsQuery

Returns a new instance of LiveDonorsQuery.



9
10
11
# File 'app/models/renalware/transplants/live_donors_query.rb', line 9

def initialize(q = {})
  @q = q
end

Instance Method Details

#callObject



13
14
15
# File 'app/models/renalware/transplants/live_donors_query.rb', line 13

def call
  search.result
end

#searchObject



17
18
19
20
21
22
23
# File 'app/models/renalware/transplants/live_donors_query.rb', line 17

def search
  @search ||= begin
    relation.ransack(q).tap do |search|
      search.sorts = DEFAULT_ORDER
    end
  end
end