Class: Quby::Questionnaires::Entities::OutcomeTable

Inherits:
Object
  • Object
show all
Includes:
ActiveModel::Model
Defined in:
lib/quby/questionnaires/entities/outcome_table.rb

Overview

OutcomeTable describes how scores are formatted in a table in outcome views

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#default_collapsedObject

Returns the value of attribute default_collapsed.



13
14
15
# File 'lib/quby/questionnaires/entities/outcome_table.rb', line 13

def default_collapsed
  @default_collapsed
end

#keyObject

Returns the value of attribute key.



13
14
15
# File 'lib/quby/questionnaires/entities/outcome_table.rb', line 13

def key
  @key
end

#nameObject

Returns the value of attribute name.



13
14
15
# File 'lib/quby/questionnaires/entities/outcome_table.rb', line 13

def name
  @name
end

#questionnaireObject

Returns the value of attribute questionnaire.



13
14
15
# File 'lib/quby/questionnaires/entities/outcome_table.rb', line 13

def questionnaire
  @questionnaire
end

#score_keysObject

Returns the value of attribute score_keys.



13
14
15
# File 'lib/quby/questionnaires/entities/outcome_table.rb', line 13

def score_keys
  @score_keys
end

#subscore_keysObject

Returns the value of attribute subscore_keys.



13
14
15
# File 'lib/quby/questionnaires/entities/outcome_table.rb', line 13

def subscore_keys
  @subscore_keys
end

Instance Method Details

#references_existing_score_keysObject



19
20
21
22
23
24
25
26
27
# File 'lib/quby/questionnaires/entities/outcome_table.rb', line 19

def references_existing_score_keys
  (score_keys - questionnaire.score_schemas.values.map(&:key)).each do |missing_key|
    errors.add :score_keys, "#{missing_key.inspect} not found in score schemas"
  end
  existing_subscore_keys = questionnaire.score_schemas.values.flat_map(&:sub_score_schemas).map(&:key)
  (subscore_keys - existing_subscore_keys).each do |missing_key|
    errors.add :subscore_keys, "#{missing_key.inspect} not found in subscore schemas"
  end
end