Files
grecia/app/models/progress_bar.rb
Javi Martín a1439d0790 Apply Layout/LineLength rubocop rule
Note we're excluding a few files:

* Configuration files that weren't generated by us
* Migration files that weren't generated by us
* The Gemfile, since it includes an important comment that must be on
  the same line as the gem declaration
* The Budget::Stats class, since the heading statistics are a mess and
  having shorter lines would require a lot of refactoring
2023-08-30 14:46:35 +02:00

26 lines
736 B
Ruby

class ProgressBar < ApplicationRecord
self.inheritance_column = nil
RANGE = (0..100)
enum kind: %i[primary secondary]
belongs_to :progressable, polymorphic: true
translates :title, touch: true
include Globalizable
translation_class_delegate :primary?
validates :progressable, presence: true
validates :kind, presence: true,
uniqueness: {
scope: [:progressable_type, :progressable_id],
conditions: -> { primary }
}
validates :percentage,
presence: true,
inclusion: { in: ->(*) { RANGE }},
numericality: { only_integer: true }
validates_translation :title, presence: true, unless: :primary?
end