We were very inconsistent regarding these rules. Personally I prefer no empty lines around blocks, clases, etc... as recommended by the Ruby style guide [1], and they're the default values in rubocop, so those are the settings I'm applying. The exception is the `private` access modifier, since we were leaving empty lines around it most of the time. That's the default rubocop rule as well. Personally I don't have a strong preference about this one. [1] https://rubystyle.guide/#empty-lines-around-bodies
23 lines
653 B
Ruby
23 lines
653 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: RANGE, numericality: { only_integer: true }
|
|
|
|
validates_translation :title, presence: true, unless: :primary?
|
|
end
|