Sha256: 3c2318000cf7142beca526311ab7633744c97c8ed2f8e4077a7a4dc05caf3ad4

Contents?: true

Size: 807 Bytes

Versions: 32

Compression:

Stored size: 807 Bytes

Contents

# frozen_string_literal: true

# 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

32 entries across 32 versions & 1 rubygems

Version Path
puppet-8.10.0 lib/puppet/util/watcher/change_watcher.rb
puppet-8.10.0-x86-mingw32 lib/puppet/util/watcher/change_watcher.rb
puppet-8.10.0-x64-mingw32 lib/puppet/util/watcher/change_watcher.rb
puppet-8.10.0-universal-darwin lib/puppet/util/watcher/change_watcher.rb
puppet-8.9.0 lib/puppet/util/watcher/change_watcher.rb
puppet-8.9.0-x86-mingw32 lib/puppet/util/watcher/change_watcher.rb
puppet-8.9.0-x64-mingw32 lib/puppet/util/watcher/change_watcher.rb
puppet-8.9.0-universal-darwin lib/puppet/util/watcher/change_watcher.rb
puppet-8.8.1 lib/puppet/util/watcher/change_watcher.rb
puppet-8.8.1-x86-mingw32 lib/puppet/util/watcher/change_watcher.rb
puppet-8.8.1-x64-mingw32 lib/puppet/util/watcher/change_watcher.rb
puppet-8.8.1-universal-darwin lib/puppet/util/watcher/change_watcher.rb
puppet-8.7.0 lib/puppet/util/watcher/change_watcher.rb
puppet-8.7.0-x86-mingw32 lib/puppet/util/watcher/change_watcher.rb
puppet-8.7.0-x64-mingw32 lib/puppet/util/watcher/change_watcher.rb
puppet-8.7.0-universal-darwin lib/puppet/util/watcher/change_watcher.rb
puppet-8.6.0 lib/puppet/util/watcher/change_watcher.rb
puppet-8.6.0-x86-mingw32 lib/puppet/util/watcher/change_watcher.rb
puppet-8.6.0-x64-mingw32 lib/puppet/util/watcher/change_watcher.rb
puppet-8.6.0-universal-darwin lib/puppet/util/watcher/change_watcher.rb