18 lines
388 B
Ruby
18 lines
388 B
Ruby
# frozen_string_literal: true
|
|
|
|
class WatchedWordSerializer < ApplicationSerializer
|
|
attributes :id, :word, :regexp, :replacement, :action, :case_sensitive, :watched_word_group_id
|
|
|
|
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
|
|
end
|