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 Instance Methods

change_current_reading_to(new_value) click to toggle source
# File lib/puppet/util/watcher/change_watcher.rb, line 26
def change_current_reading_to(new_value)
  Puppet::Util::Watcher::ChangeWatcher.new(@current, new_value, @value_reader)
end
changed?() click to toggle source
# File lib/puppet/util/watcher/change_watcher.rb, line 14
def changed?
  if uncertain?
    false
  else
    @previous != @current
  end
end
next_reading() click to toggle source
# File lib/puppet/util/watcher/change_watcher.rb, line 30
def next_reading
  change_current_reading_to(@value_reader.call)
end
uncertain?() click to toggle source
# File lib/puppet/util/watcher/change_watcher.rb, line 22
def uncertain?
  @previous.nil? || @current.nil?
end

Public Class Methods

new(previous, current, value_reader) click to toggle source
# File lib/puppet/util/watcher/change_watcher.rb, line 8
def initialize(previous, current, value_reader)
  @previous = previous
  @current = current
  @value_reader = value_reader
end
watch(reader) click to toggle source
# File lib/puppet/util/watcher/change_watcher.rb, line 4
def self.watch(reader)
  Puppet::Util::Watcher::ChangeWatcher.new(nil, nil, reader).next_reading
end