class Puppet::Util::Watcher::ChangeWatcher

Watches for changes over time. It only re-examines the values when it is requested to update readings. @api private

Public Class Methods

new(previous, current, value_reader) click to toggle source
   # File lib/puppet/util/watcher/change_watcher.rb
 9 def initialize(previous, current, value_reader)
10   @previous = previous
11   @current = current
12   @value_reader = value_reader
13 end
watch(reader) click to toggle source
  # File lib/puppet/util/watcher/change_watcher.rb
5 def self.watch(reader)
6   Puppet::Util::Watcher::ChangeWatcher.new(nil, nil, reader).next_reading
7 end

Public Instance Methods

change_current_reading_to(new_value) click to toggle source
   # File lib/puppet/util/watcher/change_watcher.rb
27 def change_current_reading_to(new_value)
28   Puppet::Util::Watcher::ChangeWatcher.new(@current, new_value, @value_reader)
29 end
changed?() click to toggle source
   # File lib/puppet/util/watcher/change_watcher.rb
15 def changed?
16   if uncertain?
17     false
18   else
19     @previous != @current
20   end
21 end
next_reading() click to toggle source
   # File lib/puppet/util/watcher/change_watcher.rb
31 def next_reading
32   change_current_reading_to(@value_reader.call)
33 end
uncertain?() click to toggle source
   # File lib/puppet/util/watcher/change_watcher.rb
23 def uncertain?
24   @previous.nil? || @current.nil?
25 end