Class: ConsulWatcher::WatchType::Key

Inherits:
Object
  • Object
show all
Includes:
FlazmRubyHelpers::Class
Defined in:
lib/consul_watcher/watch_type/key.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(watch_config) ⇒ Key

Returns a new instance of Key.



12
13
14
# File 'lib/consul_watcher/watch_type/key.rb', line 12

def initialize(watch_config)
  initialize_variables(watch_config)
end

Instance Attribute Details

#filtersObject

Returns the value of attribute filters.



11
12
13
# File 'lib/consul_watcher/watch_type/key.rb', line 11

def filters
  @filters
end

Instance Method Details

#get_changes(previous_watch_json, current_watch_json) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/consul_watcher/watch_type/key.rb', line 16

def get_changes(previous_watch_json, current_watch_json)
  json_diff = get_diff(previous_watch_json, current_watch_json)

  changes = json_diff.each.collect do |change|
    formatted_change = format_change('key', change)
    decode(formatted_change) if @decode_values
    formatted_change
  end.compact
  changes = changes.each.collect.reject {|change| @filters.filter?(change)}
  changes
end