Signed-off-by: Luke Kanies <[email protected]>
---
Local-branch: refactor/master/8233-refactor_parameter_management
lib/puppet/type.rb | 32 ---------------------------
test/ral/manager/attributes.rb | 46 ----------------------------------------
2 files changed, 0 insertions(+), 78 deletions(-)
diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb
index 5469741..efa4fd6 100644
--- a/lib/puppet/type.rb
+++ b/lib/puppet/type.rb
@@ -176,19 +176,6 @@ class Type
key_attributes | (parameters & [:provider]) | properties.collect {
|property| property.name } | parameters | metaparams
end
- # Retrieve an attribute alias, if there is one.
- def self.attr_alias(param)
- @attr_aliases[symbolize(param)]
- end
-
- # Create an alias to an existing attribute. This will cause the aliased
- # attribute to be valid when setting and retrieving values on the instance.
- def self.set_attr_alias(hash)
- hash.each do |new, old|
- @attr_aliases[symbolize(new)] = symbolize(old)
- end
- end
-
# Find the class associated with any given attribute.
def self.attrclass(name)
@attrclasses ||= {}
@@ -485,16 +472,6 @@ class Type
validattr?(name)
end
- # Return either the attribute alias or the attribute.
- def attr_alias(name)
- name = symbolize(name)
- if synonym = self.class.attr_alias(name)
- return synonym
- else
- return name
- end
- end
-
# Are we deleting this resource?
def deleting?
obj = @parameters[:ensure] and obj.should == :absent
@@ -514,8 +491,6 @@ class Type
# value, but you can also specifically return 'is' and 'should'
# values using 'object.is(:property)' or 'object.should(:property)'.
def [](name)
- name = attr_alias(name)
-
fail("Invalid parameter #{name}(#{name.inspect})") unless
self.class.validattr?(name)
if name == :name && nv = name_var
@@ -535,8 +510,6 @@ class Type
# access to always be symbols, not strings. This sets the 'should'
# value on properties, and otherwise just sets the appropriate parameter.
def []=(name,value)
- name = attr_alias(name)
-
fail("Invalid parameter #{name}") unless self.class.validattr?(name)
if name == :name && nv = name_var
@@ -593,7 +566,6 @@ class Type
# retrieve the 'should' value for a specified property
def should(name)
- name = attr_alias(name)
(prop = @parameters[name] and prop.is_a?(Puppet::Property)) ? prop.should
: nil
end
@@ -677,8 +649,6 @@ class Type
# Return a specific value for an attribute.
def value(name)
- name = attr_alias(name)
-
(obj = @parameters[name] and obj.respond_to?(:value)) ? obj.value : nil
end
@@ -1681,8 +1651,6 @@ class Type
@parameters = []
@paramhash = {}
- @attr_aliases = {}
-
@paramdoc = Hash.new { |hash,key|
key = key.intern if key.is_a?(String)
if hash.include?(key)
diff --git a/test/ral/manager/attributes.rb b/test/ral/manager/attributes.rb
index 030f38c..caa90d5 100755
--- a/test/ral/manager/attributes.rb
+++ b/test/ral/manager/attributes.rb
@@ -146,52 +146,6 @@ class TestTypeAttributes < Test::Unit::TestCase
end
end
- def test_alias_parameter
- type = mktype
- type.newparam(:name) {}
- type.newparam(:one) {}
- type.newproperty(:two) {}
-
- aliases = {
- :three => :one,
- :four => :two
- }
- aliases.each do |new, old|
- assert_nothing_raised("Could not create alias parameter #{new}") do
- type.set_attr_alias new => old
- end
- end
-
- aliases.each do |new, old|
- assert_equal(old, type.attr_alias(new), "did not return alias info for
#{new}")
- end
-
- assert_nil(type.attr_alias(:name), "got invalid alias info for name")
-
- inst = type.new(:name => "my name")
- assert(inst, "could not create instance")
-
- aliases.each do |new, old|
- val = "value #{new}"
- assert_nothing_raised do
- inst[new] = val
- end
-
- case old
- when :one # param
-
- assert_equal(
- val, inst[new],
-
- "Incorrect alias value for #{new} in []")
- else
- assert_equal(val, inst.should(new), "Incorrect alias value for #{new}
in should")
- end
- assert_equal(val, inst.value(new), "Incorrect alias value for #{new}")
- assert_equal(val, inst.value(old), "Incorrect orig value for #{old}")
- end
- end
-
# Make sure newattr handles required features correctly.
def test_newattr_and_required_features
# Make a type with some features
--
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.