Sha256: 379c0ff402d710ed75489867db89e6d5afb0194aea72cf5e91a236d3911d6863
Contents?: true
Size: 907 Bytes
Versions: 24
Compression:
Stored size: 907 Bytes
Contents
# Works in concert with Patients::SearchQuery and Patients::SearchForm. # Example usage in a controller: # # my_relation = Thing.all.joins(:patient) # filter = Patients::SearchFilter.new(search_term, request) # my_relation = patient_filter.call(my_relation) # render locals: { search_form: filter.search_form } require_dependency "renalware/patients" module Renalware module Patients class SearchFilter attr_reader :search_form def initialize(search_term, request) @search_form = build_search_form(search_term, request) end def call(relation) matching_patients = Patients::SearchQuery.new(term: search_form.term).call relation.merge(matching_patients) end def build_search_form(search_term, request) Patients::SearchForm.new( term: search_term, url: request.path ) end end end end
Version data entries
24 entries across 24 versions & 1 rubygems