Class: Renalware::Events::Event

Inherits:
ApplicationRecord show all
Includes:
Accountable, PatientScope
Defined in:
app/models/renalware/events/event.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Accountable

#first_or_create_by!, #save_by, #save_by!, #update_by

Instance Attribute Details

#disable_selection_of_event_typeObject

Virtual attribute helps us persist in the UI (across posts) whether or not the event_type can be changed. If we target e.g.

patient_new_specific_event(slug: 'something')

it can be assumed we are creating an event of a certain type (event_type.slug == ‘something’) and therefore changing that type in the new event form should be disallowed



17
18
19
# File 'app/models/renalware/events/event.rb', line 17

def disable_selection_of_event_type
  @disable_selection_of_event_type
end

Instance Method Details

#documentObject

By default an event has no embedded document but a subclass may implement one using has_document



33
34
35
# File 'app/models/renalware/events/event.rb', line 33

def document
  NullObject.instance
end

#partial_for(partial_type) ⇒ Object



60
61
62
63
64
65
66
# File 'app/models/renalware/events/event.rb', line 60

def partial_for(partial_type)
  File.join(
    "renalware/events/events",
    partial_type,
    self.class.name.demodulize.underscore
  )
end

#to_alert_partial_pathObject



48
49
50
# File 'app/models/renalware/events/event.rb', line 48

def to_alert_partial_path
  partial_for "alert"
end

#to_cell_partial_pathObject



52
53
54
# File 'app/models/renalware/events/event.rb', line 52

def to_cell_partial_path
  partial_for "cell"
end

#to_partial_pathObject Also known as: to_input_partial_path

As Events are a cross domain model, a subclass can choose to override to_partial_path etc in order to use events from another namespace for instance.



43
44
45
# File 'app/models/renalware/events/event.rb', line 43

def to_partial_path
  partial_for "inputs"
end

#to_sObject



37
38
39
# File 'app/models/renalware/events/event.rb', line 37

def to_s
  description
end

#to_toggled_cell_partial_pathObject



56
57
58
# File 'app/models/renalware/events/event.rb', line 56

def to_toggled_cell_partial_path
  partial_for "toggled_cell"
end