Class: Renalware::Events::Event

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

Direct Known Subclasses

Biopsy, Investigation, Simple, Swab, Virology::Vaccination

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



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

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



30
31
32
# File 'app/models/renalware/events/event.rb', line 30

def document
  NullObject.instance
end

#partial_for(partial_type) ⇒ Object



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

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

#to_cell_partial_pathObject



45
46
47
# File 'app/models/renalware/events/event.rb', line 45

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.



40
41
42
# File 'app/models/renalware/events/event.rb', line 40

def to_partial_path
  partial_for "inputs"
end

#to_sObject



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

def to_s
  description
end

#to_toggled_cell_partial_pathObject



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

def to_toggled_cell_partial_path
  partial_for "toggled_cell"
end