Sha256: e0b6ab3ef954602714a78cc95de43a57b8c74baeeb38fbfe5c59afdd0d2c7e1c

Contents?: true

Size: 776 Bytes

Versions: 761

Compression:

Stored size: 776 Bytes

Contents

# Watches for changes over time. It only re-examines the values when it is requested to update readings.
# @api private
class Puppet::Util::Watcher::ChangeWatcher
  def self.watch(reader)
    Puppet::Util::Watcher::ChangeWatcher.new(nil, nil, reader).next_reading
  end

  def initialize(previous, current, value_reader)
    @previous = previous
    @current = current
    @value_reader = value_reader
  end

  def changed?
    if uncertain?
      false
    else
      @previous != @current
    end
  end

  def uncertain?
    @previous.nil? || @current.nil?
  end

  def change_current_reading_to(new_value)
    Puppet::Util::Watcher::ChangeWatcher.new(@current, new_value, @value_reader)
  end

  def next_reading
    change_current_reading_to(@value_reader.call)
  end
end

Version data entries

761 entries across 761 versions & 3 rubygems

Version Path
puppet-7.34.0 lib/puppet/util/watcher/change_watcher.rb
puppet-7.34.0-x86-mingw32 lib/puppet/util/watcher/change_watcher.rb
puppet-7.34.0-x64-mingw32 lib/puppet/util/watcher/change_watcher.rb
puppet-7.34.0-universal-darwin lib/puppet/util/watcher/change_watcher.rb
puppet-7.33.0 lib/puppet/util/watcher/change_watcher.rb
puppet-7.33.0-x86-mingw32 lib/puppet/util/watcher/change_watcher.rb
puppet-7.33.0-x64-mingw32 lib/puppet/util/watcher/change_watcher.rb
puppet-7.33.0-universal-darwin lib/puppet/util/watcher/change_watcher.rb
puppet-7.32.1 lib/puppet/util/watcher/change_watcher.rb
puppet-7.32.1-x86-mingw32 lib/puppet/util/watcher/change_watcher.rb
puppet-7.32.1-x64-mingw32 lib/puppet/util/watcher/change_watcher.rb
puppet-7.32.1-universal-darwin lib/puppet/util/watcher/change_watcher.rb
puppet-7.31.0 lib/puppet/util/watcher/change_watcher.rb
puppet-7.31.0-x86-mingw32 lib/puppet/util/watcher/change_watcher.rb
puppet-7.31.0-x64-mingw32 lib/puppet/util/watcher/change_watcher.rb
puppet-7.31.0-universal-darwin lib/puppet/util/watcher/change_watcher.rb
puppet-7.30.0 lib/puppet/util/watcher/change_watcher.rb
puppet-7.30.0-x86-mingw32 lib/puppet/util/watcher/change_watcher.rb
puppet-7.30.0-x64-mingw32 lib/puppet/util/watcher/change_watcher.rb
puppet-7.30.0-universal-darwin lib/puppet/util/watcher/change_watcher.rb