Sha256: 39a48c3435a8a26ecbfa2c338f2aaa3695a4005d91de3d87a80e9afafbd027e0

Contents?: true

Size: 1.01 KB

Versions: 3

Compression:

Stored size: 1.01 KB

Contents

module Quby
  module Questionnaires
    module Entities
      # SubscoreSchema instances describe each key that could be returned in a score result hash

      class SubscoreSchema
        include ActiveModel::Model

        # The key this subscore has in the hash returned by the score
        attr_accessor :key
        # The description of this subscore in the context of the score, like 'Mean', 'T-Score' or 'Interpretation'
        attr_accessor :label
        # The shortened key that will used as the field/column name for csv and oru exports,
        # excluding the questionnaire key part
        attr_accessor :export_key

        validates :key, :label, :export_key, presence: true
        validate :key_is_symbol
        validate :export_key_is_symbol

        def key_is_symbol
          errors.add(:key, 'is not a symbol') unless key.is_a?(Symbol)
        end

        def export_key_is_symbol
          errors.add(:export_key, 'is not a symbol') unless export_key.is_a?(Symbol)
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
quby-5.6.6 lib/quby/questionnaires/entities/subscore_schema.rb
quby-5.6.5 lib/quby/questionnaires/entities/subscore_schema.rb
quby-5.6.3 lib/quby/questionnaires/entities/subscore_schema.rb