diff options
author | Luke Kanies <luke@madstop.com> | 2008-04-08 11:39:29 -0500 |
---|---|---|
committer | Luke Kanies <luke@madstop.com> | 2008-04-08 11:39:29 -0500 |
commit | 768315bd6e8ecd064ab473187c10b4633f09523c (patch) | |
tree | b228e2caf578ad312b926cbe5be1d51bcfab7486 /lib/puppet/indirector/request.rb | |
parent | 38f0f483faeba28d12a5f4e1d52e8d10ab96e68b (diff) | |
download | puppet-768315bd6e8ecd064ab473187c10b4633f09523c.tar.gz puppet-768315bd6e8ecd064ab473187c10b4633f09523c.tar.xz puppet-768315bd6e8ecd064ab473187c10b4633f09523c.zip |
Adding the ability for indirection requests to be created
with instances instead of just keys.
Diffstat (limited to 'lib/puppet/indirector/request.rb')
-rw-r--r-- | lib/puppet/indirector/request.rb | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/lib/puppet/indirector/request.rb b/lib/puppet/indirector/request.rb index a5495641d..708862b28 100644 --- a/lib/puppet/indirector/request.rb +++ b/lib/puppet/indirector/request.rb @@ -3,10 +3,17 @@ require 'puppet/indirector' # Provide any attributes or functionality needed for indirected # instances. class Puppet::Indirector::Request - attr_accessor :indirection_name, :key, :method, :options + attr_accessor :indirection_name, :key, :method, :options, :instance def initialize(indirection_name, key, method, options = {}) - @indirection_name, @key, @method, @options = indirection_name, key, method, (options || {}) + @indirection_name, @method, @options = indirection_name, method, (options || {}) + + if key.is_a?(String) or key.is_a?(Symbol) + @key = key + else + @instance = key + @key = @instance.name + end raise ArgumentError, "Request options must be a hash, not %s" % @options.class unless @options.is_a?(Hash) end |