Sha256: 7d6057086b17ce86d476d448fd3e676e413fa8eedd5c8747335687c0faa67a6a

Contents?: true

Size: 806 Bytes

Versions: 20

Compression:

Stored size: 806 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

20 entries across 20 versions & 1 rubygems

Version Path
puppet-8.3.0 lib/puppet/util/watcher/change_watcher.rb
puppet-8.3.0-x86-mingw32 lib/puppet/util/watcher/change_watcher.rb
puppet-8.3.0-x64-mingw32 lib/puppet/util/watcher/change_watcher.rb
puppet-8.3.0-universal-darwin lib/puppet/util/watcher/change_watcher.rb
puppet-8.3.1 lib/puppet/util/watcher/change_watcher.rb
puppet-8.3.1-x86-mingw32 lib/puppet/util/watcher/change_watcher.rb
puppet-8.3.1-x64-mingw32 lib/puppet/util/watcher/change_watcher.rb
puppet-8.3.1-universal-darwin lib/puppet/util/watcher/change_watcher.rb
puppet-8.2.0 lib/puppet/util/watcher/change_watcher.rb
puppet-8.2.0-x86-mingw32 lib/puppet/util/watcher/change_watcher.rb
puppet-8.2.0-x64-mingw32 lib/puppet/util/watcher/change_watcher.rb
puppet-8.2.0-universal-darwin lib/puppet/util/watcher/change_watcher.rb
puppet-8.1.0 lib/puppet/util/watcher/change_watcher.rb
puppet-8.1.0-x86-mingw32 lib/puppet/util/watcher/change_watcher.rb
puppet-8.1.0-x64-mingw32 lib/puppet/util/watcher/change_watcher.rb
puppet-8.1.0-universal-darwin lib/puppet/util/watcher/change_watcher.rb
puppet-8.0.1 lib/puppet/util/watcher/change_watcher.rb
puppet-8.0.1-x86-mingw32 lib/puppet/util/watcher/change_watcher.rb
puppet-8.0.1-x64-mingw32 lib/puppet/util/watcher/change_watcher.rb
puppet-8.0.1-universal-darwin lib/puppet/util/watcher/change_watcher.rb