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