summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2009-10-29 09:29:47 -0700
committertest branch <puppet-dev@googlegroups.com>2010-02-17 06:50:53 -0800
commit828098734fd219d40dd1e9546fc829061cdeeb7e (patch)
tree101dff0586e6a326daaa9c13accca171a08e3d3a
parentad90900e68a2c406f0e95dba3f780ad135415b14 (diff)
downloadpuppet-828098734fd219d40dd1e9546fc829061cdeeb7e.tar.gz
puppet-828098734fd219d40dd1e9546fc829061cdeeb7e.tar.xz
puppet-828098734fd219d40dd1e9546fc829061cdeeb7e.zip
Adding "type" instance method to enhance Demeterness
Signed-off-by: Luke Kanies <luke@madstop.com>
-rw-r--r--lib/puppet/type.rb4
-rwxr-xr-xspec/unit/type.rb4
2 files changed, 8 insertions, 0 deletions
diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb
index 2f7b57afc..84f0b93d0 100644
--- a/lib/puppet/type.rb
+++ b/lib/puppet/type.rb
@@ -590,6 +590,10 @@ class Type
rethash
end
+ def type
+ self.class.name
+ end
+
# Return a specific value for an attribute.
def value(name)
name = attr_alias(name)
diff --git a/spec/unit/type.rb b/spec/unit/type.rb
index 11bedaaa2..575b6c093 100755
--- a/spec/unit/type.rb
+++ b/spec/unit/type.rb
@@ -98,6 +98,10 @@ describe Puppet::Type do
resource.source_descriptors.should == {:version=>50, :tags=>["mount", "foo"], :path=>"/Mount[foo]"}
end
+ it "should consider its type to be the name of its class" do
+ Puppet::Type.type(:mount).new(:name => "foo").type.should == :mount
+ end
+
describe "when choosing a default provider" do
it "should choose the provider with the highest specificity" do
# Make a fake type