2019-05-02 17:17:27 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-06-28 15:56:44 -05:00
|
|
|
class WatchedWordSerializer < ApplicationSerializer
|
2024-05-06 10:08:34 -05:00
|
|
|
attributes :id,
|
|
|
|
:word,
|
|
|
|
:regexp,
|
|
|
|
:replacement,
|
|
|
|
:action,
|
|
|
|
:case_sensitive,
|
|
|
|
:watched_word_group_id,
|
|
|
|
:html
|
2021-05-21 09:50:24 -05:00
|
|
|
|
|
|
|
def regexp
|
2023-06-09 05:22:41 -05:00
|
|
|
WordWatcher.word_to_regexp(word, engine: :js)
|
2021-05-21 09:50:24 -05:00
|
|
|
end
|
|
|
|
|
2017-06-28 15:56:44 -05:00
|
|
|
def action
|
|
|
|
WatchedWord.actions[object.action]
|
|
|
|
end
|
2021-02-25 06:00:58 -06:00
|
|
|
|
|
|
|
def include_replacement?
|
2021-03-22 15:32:18 -05:00
|
|
|
WatchedWord.has_replacement?(action)
|
2021-02-25 06:00:58 -06:00
|
|
|
end
|
2024-05-06 10:08:34 -05:00
|
|
|
|
|
|
|
def include_html?
|
|
|
|
object.action == WatchedWord.actions[:replace] && object.html
|
|
|
|
end
|
2017-06-28 15:56:44 -05:00
|
|
|
end
|