mirror of
https://github.com/discourse/discourse.git
synced 2024-12-21 08:33:43 +08:00
22 lines
460 B
Ruby
22 lines
460 B
Ruby
# frozen_string_literal: true
|
|
|
|
# TODO(@keegan): Remove after removing SiteSetting.summarization_strategy
|
|
|
|
class SummarizationValidator
|
|
def initialize(opts = {})
|
|
@opts = opts
|
|
end
|
|
|
|
def valid_value?(val)
|
|
strategy = Summarization::Base.find_strategy(val)
|
|
|
|
return true unless strategy
|
|
|
|
strategy.correctly_configured?.tap { |is_valid| @strategy = strategy unless is_valid }
|
|
end
|
|
|
|
def error_message
|
|
@strategy.configuration_hint
|
|
end
|
|
end
|