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