Class: Renalware::Patients::SearchFilter

Inherits:
Object
  • Object
show all
Defined in:
app/models/renalware/patients/search_filter.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(search_term, request) ⇒ SearchFilter

Returns a new instance of SearchFilter.



17
18
19
# File 'app/models/renalware/patients/search_filter.rb', line 17

def initialize(search_term, request)
  @search_form = build_search_form(search_term, request)
end

Instance Attribute Details

#search_formObject (readonly)

Returns the value of attribute search_form.



15
16
17
# File 'app/models/renalware/patients/search_filter.rb', line 15

def search_form
  @search_form
end

Instance Method Details

#build_search_form(search_term, request) ⇒ Object



26
27
28
29
30
31
# File 'app/models/renalware/patients/search_filter.rb', line 26

def build_search_form(search_term, request)
  Patients::SearchForm.new(
    term: search_term,
    url: request.path
  )
end

#call(relation) ⇒ Object



21
22
23
24
# File 'app/models/renalware/patients/search_filter.rb', line 21

def call(relation)
  matching_patients = Patients::SearchQuery.new(term: search_form.term).call
  relation.merge(matching_patients)
end