This has been superceded by Puppet::Type.metaparameter
Signed-off-by: Luke Kanies <[email protected]>
---
Local-branch: refactor/master/8233-refactor_parameter_management
lib/puppet/property.rb | 2 +-
lib/puppet/resource/type.rb | 2 +-
lib/puppet/type.rb | 9 ++++-----
lib/puppet/type/port.rb | 2 +-
spec/unit/property_spec.rb | 25 -------------------------
spec/unit/type_spec.rb | 12 ++++++------
6 files changed, 13 insertions(+), 39 deletions(-)
diff --git a/lib/puppet/property.rb b/lib/puppet/property.rb
index 12f496a..ef1b194 100644
--- a/lib/puppet/property.rb
+++ b/lib/puppet/property.rb
@@ -141,7 +141,7 @@ class Puppet::Property < Puppet::Parameter
def initialize(hash = {})
super
- if ! self.metaparam? and klass =
Puppet::Type.metaparamclass(self.class.name)
+ if ! self.metaparam? and klass =
Puppet::Type.metaparameter(self.class.name)
setup_shadow(klass)
end
end
diff --git a/lib/puppet/resource/type.rb b/lib/puppet/resource/type.rb
index f8d820b..8d7f51a 100644
--- a/lib/puppet/resource/type.rb
+++ b/lib/puppet/resource/type.rb
@@ -330,7 +330,7 @@ class Puppet::Resource::Type
end
def warn_if_metaparam(param, default)
- return unless Puppet::Type.metaparamclass(param)
+ return unless Puppet::Type.metaparameter(param)
if default
warnonce "#{param} is a metaparam; this value will inherit to all
contained resources"
diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb
index a399ad6..fe2883a 100644
--- a/lib/puppet/type.rb
+++ b/lib/puppet/type.rb
@@ -254,6 +254,10 @@ class Type
Puppet::Type.valid_parameter?(param)
end
+ def self.metaparameter(name)
+ Puppet::Type.parameter(name)
+ end
+
def self.metaparameters
Puppet::Type.parameters
end
@@ -270,11 +274,6 @@ class Type
metaparameters
end
- # Find the metaparameter class associated with a given metaparameter name.
- def self.metaparamclass(name)
- Puppet::Type.parameter(name)
- end
-
# Find a parameter, property, or metaparameter class by name
def self.parameter_class(name)
parameter(name)
diff --git a/lib/puppet/type/port.rb b/lib/puppet/type/port.rb
index e199885..4545e81 100755
--- a/lib/puppet/type/port.rb
+++ b/lib/puppet/type/port.rb
@@ -90,7 +90,7 @@
# unless value == "absent" or value == :absent
# # Add the :alias metaparam in addition to the property
# @resource.newmetaparam(
-# @resource.class.metaparamclass(:alias), value
+# @resource.class.metaparameter(:alias), value
# )
# end
# value
diff --git a/spec/unit/property_spec.rb b/spec/unit/property_spec.rb
index 7728b5d..0f63e41 100755
--- a/spec/unit/property_spec.rb
+++ b/spec/unit/property_spec.rb
@@ -146,31 +146,6 @@ describe Puppet::Property do
end
end
- describe "when shadowing metaparameters" do
- before do
- @shadow_class = Class.new(Puppet::Property) do
- @name = :alias
- end
- @shadow_class.initvars
- end
-
- it "should create an instance of the metaparameter at initialization" do
- Puppet::Type.metaparamclass(:alias).expects(:new).with(:resource =>
@resource)
-
- @shadow_class.new :resource => @resource
- end
-
- it "should munge values using the shadow's munge method" do
- shadow = mock 'shadow'
- Puppet::Type.metaparamclass(:alias).expects(:new).returns shadow
-
- shadow.expects(:munge).with "foo"
-
- property = @shadow_class.new :resource => @resource
- property.munge("foo")
- end
- end
-
describe "when defining new values" do
it "should define a method for each value created with a block that's not
a regex" do
@class.newvalue(:foo) { }
diff --git a/spec/unit/type_spec.rb b/spec/unit/type_spec.rb
index 4997a89..c3eb8c3 100755
--- a/spec/unit/type_spec.rb
+++ b/spec/unit/type_spec.rb
@@ -662,7 +662,7 @@ describe Puppet::Type do
end
it "should have a 'stage' metaparam" do
- Puppet::Type.metaparamclass(:stage).should be_instance_of(Class)
+ Puppet::Type.metaparameter(:stage).should be_instance_of(Class)
end
end
@@ -678,7 +678,7 @@ describe Puppet::Type::RelationshipMetaparam do
describe "when munging relationships" do
before do
@resource = Puppet::Type.type(:mount).new :name => "/foo"
- @metaparam = Puppet::Type.metaparamclass(:require).new :resource =>
@resource
+ @metaparam = Puppet::Type.metaparameter(:require).new :resource =>
@resource
end
it "should accept Puppet::Resource instances" do
@@ -692,14 +692,14 @@ describe Puppet::Type::RelationshipMetaparam do
end
it "should be able to validate relationships" do
- Puppet::Type.metaparamclass(:require).new(:resource =>
mock("resource")).should respond_to(:validate_relationship)
+ Puppet::Type.metaparameter(:require).new(:resource =>
mock("resource")).should respond_to(:validate_relationship)
end
it "should fail if any specified resource is not found in the catalog" do
catalog = mock 'catalog'
resource = stub 'resource', :catalog => catalog, :ref => "resource"
- param = Puppet::Type.metaparamclass(:require).new(:resource => resource,
:value => %w{Foo[bar] Class[test]})
+ param = Puppet::Type.metaparameter(:require).new(:resource => resource,
:value => %w{Foo[bar] Class[test]})
catalog.expects(:resource).with("Foo[bar]").returns "something"
catalog.expects(:resource).with("Class[Test]").returns nil
@@ -710,7 +710,7 @@ describe Puppet::Type::RelationshipMetaparam do
end
end
-describe Puppet::Type.metaparamclass(:check) do
+describe Puppet::Type.metaparameter(:check) do
it "should warn and create an instance of ':audit'" do
file = Puppet::Type.type(:file).new :path => "/foo"
file.expects(:warning)
@@ -719,7 +719,7 @@ describe Puppet::Type.metaparamclass(:check) do
end
end
-describe Puppet::Type.metaparamclass(:audit) do
+describe Puppet::Type.metaparameter(:audit) do
before do
@resource = Puppet::Type.type(:file).new :path => "/foo"
end
--
1.7.3.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.