Class: Renalware::Clinics::AppointmentQuery

Inherits:
Object
  • Object
show all
Defined in:
app/models/renalware/clinics/appointment_query.rb

Defined Under Namespace

Classes: QueryableAppointment

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(q = {}) ⇒ AppointmentQuery

Returns a new instance of AppointmentQuery.



10
11
12
13
# File 'app/models/renalware/clinics/appointment_query.rb', line 10

def initialize(q = {})
  @q = q
  @q[:s] = "starts_at ASC" if @q[:s].blank?
end

Instance Attribute Details

#appointmentsObject (readonly)

Returns the value of attribute appointments.



8
9
10
# File 'app/models/renalware/clinics/appointment_query.rb', line 8

def appointments
  @appointments
end

#queryObject (readonly)

Returns the value of attribute query.



8
9
10
# File 'app/models/renalware/clinics/appointment_query.rb', line 8

def query
  @query
end

Instance Method Details

#callObject



15
16
17
18
19
20
21
# File 'app/models/renalware/clinics/appointment_query.rb', line 15

def call
  search.result.includes(
    :clinic,
    :consultant,
    patient: [current_modality: [:description]]
  )
end

#searchObject



23
24
25
# File 'app/models/renalware/clinics/appointment_query.rb', line 23

def search
  @search ||= QueryableAppointment.ransack(@q)
end