class Puppet::Util::Watcher::PeriodicWatcher
Monitor a given watcher for changes on a periodic interval.
Public Class Methods
new(watcher, timer)
click to toggle source
@param watcher [Puppet::Util::Watcher::ChangeWatcher] a watcher for the value to watch @param timer [Puppet::Util::Watcher::Timer] A timer to determine when to
recheck the watcher. If the timeout of the timer is negative, then the watched value is always considered to be changed
# File lib/puppet/util/watcher/periodic_watcher.rb 7 def initialize(watcher, timer) 8 @watcher = watcher 9 @timer = timer 10 11 @timer.start 12 end
Public Instance Methods
changed?()
click to toggle source
@return [true, false] If the file has changed since it was last checked.
# File lib/puppet/util/watcher/periodic_watcher.rb 15 def changed? 16 return true if always_consider_changed? 17 18 @watcher = examine_watched_info(@watcher) 19 @watcher.changed? 20 end
Private Instance Methods
always_consider_changed?()
click to toggle source
# File lib/puppet/util/watcher/periodic_watcher.rb 24 def always_consider_changed? 25 @timer.timeout < 0 26 end
examine_watched_info(known)
click to toggle source
# File lib/puppet/util/watcher/periodic_watcher.rb 28 def examine_watched_info(known) 29 if @timer.expired? 30 @timer.start 31 known.next_reading 32 else 33 known 34 end 35 end