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 8 def initialize(previous, current, value_reader) 9 @previous = previous 10 @current = current 11 @value_reader = value_reader 12 end
watch(reader)
click to toggle source
# File lib/puppet/util/watcher/change_watcher.rb 4 def self.watch(reader) 5 Puppet::Util::Watcher::ChangeWatcher.new(nil, nil, reader).next_reading 6 end
Public Instance Methods
change_current_reading_to(new_value)
click to toggle source
# File lib/puppet/util/watcher/change_watcher.rb 26 def change_current_reading_to(new_value) 27 Puppet::Util::Watcher::ChangeWatcher.new(@current, new_value, @value_reader) 28 end
changed?()
click to toggle source
# File lib/puppet/util/watcher/change_watcher.rb 14 def changed? 15 if uncertain? 16 false 17 else 18 @previous != @current 19 end 20 end
next_reading()
click to toggle source
# File lib/puppet/util/watcher/change_watcher.rb 30 def next_reading 31 change_current_reading_to(@value_reader.call) 32 end
uncertain?()
click to toggle source
# File lib/puppet/util/watcher/change_watcher.rb 22 def uncertain? 23 @previous.nil? || @current.nil? 24 end