discourse/app/serializers/watched_word_serializer.rb
Bianca Nenciu efd6394cd8
FEATURE: Show an error message if regex is invalid (#13164)
The server cannot always determine when a watched word regular
expression is invalid and this commit implements the check on the client
side.
2021-05-27 19:42:43 +03:00

18 lines
334 B
Ruby

# frozen_string_literal: true
class WatchedWordSerializer < ApplicationSerializer
attributes :id, :word, :regexp, :replacement, :action
def regexp
WordWatcher.word_to_regexp(word)
end
def action
WatchedWord.actions[object.action]
end
def include_replacement?
WatchedWord.has_replacement?(action)
end
end