Class: KB::Assessment

Inherits:
BaseModel show all
Includes:
Findable, Listable
Defined in:
lib/kb/models/assessment.rb

Constant Summary collapse

STRING_FIELDS =
%i[key pet_key urgency].freeze
FIELDS =
[*STRING_FIELDS, :date, :should_stop, :finished, :conditions, :symptoms, :next_question].freeze

Instance Attribute Summary

Attributes inherited from BaseModel

#persisted

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Findable

#reload

Methods inherited from BaseModel

#==, define_attribute_methods, define_attributes, #initialize, #persist!, #persisted?

Methods included from Inspectionable

#inspect

Constructor Details

This class inherits a constructor from KB::BaseModel

Class Method Details

.all(filters = {}) ⇒ Object



15
16
17
18
19
# File 'lib/kb/models/assessment.rb', line 15

def all(filters = {})
  filters[:locale] ||= I18n.locale
  filters[:pet_key] = filters[:user] if filters[:user].present?
  super(filters)
end

.by_pet(pet) ⇒ Object



11
12
13
# File 'lib/kb/models/assessment.rb', line 11

def by_pet(pet)
  all(user: pet.kb_key)
end

.find(key, params = {}) ⇒ Object



21
22
23
24
# File 'lib/kb/models/assessment.rb', line 21

def find(key, params = {})
  params[:locale] ||= I18n.locale
  super(key, params)
end

Instance Method Details

#urgentObject



50
51
52
53
54
# File 'lib/kb/models/assessment.rb', line 50

def urgent
  return false if urgency == 'low'

  true
end