summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/puppet/type.rb10
-rwxr-xr-xspec/unit/type.rb17
2 files changed, 20 insertions, 7 deletions
diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb
index 85f72f79a..da274df88 100644
--- a/lib/puppet/type.rb
+++ b/lib/puppet/type.rb
@@ -601,10 +601,7 @@ class Type
# return the value of a parameter
def parameter(name)
- unless name.is_a? Symbol
- name = name.intern
- end
- return @parameters[name].value
+ @parameters[name.to_sym]
end
# Is the named property defined?
@@ -615,8 +612,9 @@ class Type
return @parameters.include?(name)
end
- # return an actual type by name; to return the value, use 'inst[name]'
- # FIXME this method should go away
+ # Return an actual property instance by name; to return the value, use 'resource[param]'
+ # LAK:NOTE(20081028) Since the 'parameter' method is now a superset of this method,
+ # this one should probably go away at some point.
def property(name)
if obj = @parameters[symbolize(name)] and obj.is_a?(Puppet::Property)
return obj
diff --git a/spec/unit/type.rb b/spec/unit/type.rb
index 4c0cb5077..b07f781ed 100755
--- a/spec/unit/type.rb
+++ b/spec/unit/type.rb
@@ -3,7 +3,22 @@
require File.dirname(__FILE__) + '/../spec_helper'
describe Puppet::Type do
- describe "when retrieving current properties" do
+ it "should be able to retrieve a property by name" do
+ resource = Puppet::Type.type(:mount).create(:name => "foo", :fstype => "bar", :pass => 1, :ensure => :present)
+ resource.property(:fstype).must be_instance_of(Puppet::Type.type(:mount).attrclass(:fstype))
+ end
+
+ it "should be able to retrieve a parameter by name" do
+ resource = Puppet::Type.type(:mount).create(:name => "foo", :fstype => "bar", :pass => 1, :ensure => :present)
+ resource.parameter(:name).must be_instance_of(Puppet::Type.type(:mount).attrclass(:name))
+ end
+
+ it "should be able to retrieve a property by name using the :parameter method" do
+ resource = Puppet::Type.type(:mount).create(:name => "foo", :fstype => "bar", :pass => 1, :ensure => :present)
+ resource.parameter(:fstype).must be_instance_of(Puppet::Type.type(:mount).attrclass(:fstype))
+ end
+
+ describe "when retrieving current property values" do
# Use 'mount' as an example, because it doesn't override 'retrieve'
before do
@resource = Puppet::Type.type(:mount).create(:name => "foo", :fstype => "bar", :pass => 1, :ensure => :present)