Sha256: 839ff4974bcf66ef22c1e7dbf48e4a266bba6b1c62fba4e1019b40a12318b34d

Contents?: true

Size: 616 Bytes

Versions: 3

Compression:

Stored size: 616 Bytes

Contents

require 'active_support/core_ext/hash/indifferent_access'

class WatchQueryTask < Task
  def type_name
    'Watch query'
  end

  def perform
    result = SearchKeys.new(backend, trigger).result.map(&:with_indifferent_access)
    if data[:initialized]
      notify(data[:old_value], result) if data[:old_value] != result
    else
      data[:initialized] = true
    end

    data[:old_value] = result
    save
  end

  def notify(old_value, new_value)
    msg = "Value of key '#{trigger}' has changed from #{old_value.inspect} to #{new_value.inspect}"
    Notification.create!(reporter: name, message: msg)
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
redis_monitor-0.3.3 lib/engine/app/models/watch_query_task.rb
redis_monitor-0.3.2 lib/engine/app/models/watch_query_task.rb
redis_monitor-0.3 lib/engine/app/models/watch_query_task.rb