Class: Renalware::Events::EventQuery
- Inherits:
-
Object
- Object
- Renalware::Events::EventQuery
- Defined in:
- app/models/renalware/events/event_query.rb
Instance Attribute Summary collapse
-
#patient ⇒ Object
readonly
Returns the value of attribute patient.
-
#query ⇒ Object
readonly
Returns the value of attribute query.
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(patient:, query: {}) ⇒ EventQuery
constructor
A new instance of EventQuery.
- #search ⇒ Object
Constructor Details
#initialize(patient:, query: {}) ⇒ EventQuery
Returns a new instance of EventQuery.
10 11 12 13 14 |
# File 'app/models/renalware/events/event_query.rb', line 10 def initialize(patient:, query: {}) @query = query @patient = patient @query[:s] = "datetime DESC" if @query[:s].blank? end |
Instance Attribute Details
#patient ⇒ Object (readonly)
Returns the value of attribute patient.
8 9 10 |
# File 'app/models/renalware/events/event_query.rb', line 8 def patient @patient end |
#query ⇒ Object (readonly)
Returns the value of attribute query.
8 9 10 |
# File 'app/models/renalware/events/event_query.rb', line 8 def query @query end |
Instance Method Details
#call ⇒ Object
16 17 18 19 20 21 22 23 |
# File 'app/models/renalware/events/event_query.rb', line 16 def call search.result.for_patient(patient) .includes(:event_type) .eager_load(:event_type) .includes(:created_by) .eager_load(:created_by) .ordered end |
#search ⇒ Object
25 26 27 |
# File 'app/models/renalware/events/event_query.rb', line 25 def search @search ||= Event.ransack(query) end |