Signed-off-by: Luke Kanies <[email protected]>
---
lib/puppet/parser/resource.rb | 4 ++++
spec/unit/parser/resource.rb | 10 ++++++++++
2 files changed, 14 insertions(+), 0 deletions(-)
diff --git a/lib/puppet/parser/resource.rb b/lib/puppet/parser/resource.rb
index 651ed42..63d028c 100644
--- a/lib/puppet/parser/resource.rb
+++ b/lib/puppet/parser/resource.rb
@@ -56,6 +56,10 @@ class Puppet::Parser::Resource
end
end
+ def []=(param, value)
+ set_parameter(param, value)
+ end
+
def builtin=(bool)
@ref.builtin = bool
end
diff --git a/spec/unit/parser/resource.rb b/spec/unit/parser/resource.rb
index 3f08de9..913fd1e 100755
--- a/spec/unit/parser/resource.rb
+++ b/spec/unit/parser/resource.rb
@@ -75,6 +75,16 @@ describe Puppet::Parser::Resource do
@resource.to_ral.should == "yay"
end
+ it "should be able to use the indexing operator to access parameters" do
+ resource = Puppet::Parser::Resource.new(:type => "resource", :title =>
"testing", :source => "source", :scope => "scope")
+ resource["foo"] = "bar"
+ resource["foo"].should == "bar"
+ end
+
+ it "should return the title when asked for a parameter named 'title'" do
+ Puppet::Parser::Resource.new(:type => "resource", :title => "testing",
:source => "source", :scope => "scope")[:title].should == "testing"
+ end
+
describe "when initializing" do
before do
@arguments = {:type => "resource", :title => "testing", :scope =>
stub('scope', :source => mock('source'))}
--
1.6.1
--
You received this message because you are subscribed to the Google Groups
"Puppet Developers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/puppet-dev?hl=en.