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