Sha256: c5feb7f60a32f6ffea5c8dcf81c2259e01319bb62d1579c055b0338e17ad1fb6

Contents?: true

Size: 709 Bytes

Versions: 14

Compression:

Stored size: 709 Bytes

Contents

require 'puppet/indirector/terminus'

# Manage a memory-cached list of instances.
class Puppet::Indirector::Memory < Puppet::Indirector::Terminus
  def initialize
    @instances = {}
  end

  def destroy(request)
    raise ArgumentError.new("Could not find #{request.key} to destroy") unless @instances.include?(request.key)
    @instances.delete(request.key)
  end

  def find(request)
    @instances[request.key]
  end

  def search(request)
    found_keys = @instances.keys.find_all { |key| key.include?(request.key) }
    found_keys.collect { |key| @instances[key] }
  end

  def head(request)
    not find(request).nil?
  end

  def save(request)
    @instances[request.key] = request.instance
  end
end

Version data entries

14 entries across 14 versions & 1 rubygems

Version Path
puppet-3.4.3 lib/puppet/indirector/memory.rb
puppet-3.4.2 lib/puppet/indirector/memory.rb
puppet-3.4.1 lib/puppet/indirector/memory.rb
puppet-3.4.0 lib/puppet/indirector/memory.rb
puppet-3.4.0.rc2 lib/puppet/indirector/memory.rb
puppet-3.4.0.rc1 lib/puppet/indirector/memory.rb
puppet-3.3.2 lib/puppet/indirector/memory.rb
puppet-3.3.1 lib/puppet/indirector/memory.rb
puppet-3.3.1.rc3 lib/puppet/indirector/memory.rb
puppet-3.3.1.rc2 lib/puppet/indirector/memory.rb
puppet-3.3.1.rc1 lib/puppet/indirector/memory.rb
puppet-3.3.0 lib/puppet/indirector/memory.rb
puppet-3.3.0.rc3 lib/puppet/indirector/memory.rb
puppet-3.3.0.rc2 lib/puppet/indirector/memory.rb