Class: Renalware::Patients::WorryQuery
- Inherits:
-
Object
- Object
- Renalware::Patients::WorryQuery
- Defined in:
- app/models/renalware/patients/worry_query.rb
Instance Attribute Summary collapse
-
#query_params ⇒ Object
readonly
Returns the value of attribute query_params.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(query_params) ⇒ WorryQuery
constructor
A new instance of WorryQuery.
- #search ⇒ Object
Constructor Details
#initialize(query_params) ⇒ WorryQuery
Returns a new instance of WorryQuery.
10 11 12 13 |
# File 'app/models/renalware/patients/worry_query.rb', line 10 def initialize(query_params) @query_params = query_params @query_params[:s] = "date_time DESC" if @query_params[:s].blank? end |
Instance Attribute Details
#query_params ⇒ Object (readonly)
Returns the value of attribute query_params.
8 9 10 |
# File 'app/models/renalware/patients/worry_query.rb', line 8 def query_params @query_params end |
Instance Method Details
#call ⇒ Object
15 16 17 18 19 20 |
# File 'app/models/renalware/patients/worry_query.rb', line 15 def call search .result .includes(:created_by, patient: { current_modality: [:description] }) .order(created_at: :asc) end |
#search ⇒ Object
22 23 24 |
# File 'app/models/renalware/patients/worry_query.rb', line 22 def search @search ||= Worry.ransack(query_params) end |