discourse/app/serializers/watched_word_serializer.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

29 lines
579 B
Ruby
Raw Normal View History

# frozen_string_literal: true
class WatchedWordSerializer < ApplicationSerializer
attributes :id,
:word,
:regexp,
:replacement,
:action,
:case_sensitive,
:watched_word_group_id,
:html
def regexp
WordWatcher.word_to_regexp(word, engine: :js)
end
def action
WatchedWord.actions[object.action]
end
def include_replacement?
WatchedWord.has_replacement?(action)
end
def include_html?
object.action == WatchedWord.actions[:replace] && object.html
end
end