summaryrefslogtreecommitdiffstats
path: root/lib/puppet/indirector/memory.rb
blob: b97e6ffb647b177d594b5c3c66b5b1c0014dd6d7 (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(name)
        raise ArgumentError.new("Could not find %s to destroy" % name) unless @instances.include?(name)
        @instances.delete(name)
    end

    def find(name)
        @instances[name]
    end

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