summaryrefslogtreecommitdiffstats
path: root/lib/puppet/indirector/memory.rb
blob: 19acc14e2951e346971d46bcec1954ddea57343a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
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 %s to destroy" % request.key) unless @instances.include?(request.key)
        @instances.delete(request.key)
    end

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

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