mirror of
https://github.com/discourse/discourse.git
synced 2024-12-21 11:13:44 +08:00
6ca2396b12
Why this change? The logic for validating a theme setting's value and default value was not consistent as each part of the code would implement its own logic. This is not ideal as the default value may be validated differently than when we are setting a new value. Therefore, this commit seeks to refactor all the validation logic for a theme setting's value into a single service class. What does this change do? Introduce the `ThemeSettingsValidator` service class which holds all the necessary helper methods required to validate a theme setting's value
16 lines
253 B
Ruby
16 lines
253 B
Ruby
# frozen_string_literal: true
|
|
|
|
class ThemeSettingsManager::Integer < ThemeSettingsManager
|
|
def self.cast(value)
|
|
value.to_i
|
|
end
|
|
|
|
def value
|
|
self.class.cast(super)
|
|
end
|
|
|
|
def value=(new_value)
|
|
super(self.class.cast(new_value))
|
|
end
|
|
end
|