Class: WatchedWordListSerializer

Inherits:
ApplicationSerializer show all
Defined in:
app/serializers/watched_word_list_serializer.rb

Instance Method Summary collapse

Methods inherited from ApplicationSerializer

expire_cache_fragment!, fragment_cache

Methods inherited from ActiveModel::Serializer

#include!

Instance Method Details

#actionsObject



6
7
8
9
10
11
12
# File 'app/serializers/watched_word_list_serializer.rb', line 6

def actions
  if SiteSetting.tagging_enabled
    WatchedWord.actions.keys
  else
    WatchedWord.actions.keys.filter { |k| k != :tag }
  end
end

#compiled_regular_expressionsObject



18
19
20
21
22
23
24
# File 'app/serializers/watched_word_list_serializer.rb', line 18

def compiled_regular_expressions
  expressions = {}
  actions.each do |action|
    expressions[action] = WordWatcher.serializable_word_matcher_regexp(action, engine: :js)
  end
  expressions
end

#wordsObject



14
15
16
# File 'app/serializers/watched_word_list_serializer.rb', line 14

def words
  object.map { |word| WatchedWordSerializer.new(word, root: false) }
end