summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2008-09-23 14:52:57 -0500
committerLuke Kanies <luke@madstop.com>2008-09-23 14:52:57 -0500
commit8d5ded09b9c9c944695c015e6e95b10ccebd6fb5 (patch)
tree5e3238d1a69b84fbf307ce931c37117a70adf551
parent5fbdc49dfdb39351c7f2d9e535577efc177cf838 (diff)
downloadpuppet-8d5ded09b9c9c944695c015e6e95b10ccebd6fb5.tar.gz
puppet-8d5ded09b9c9c944695c015e6e95b10ccebd6fb5.tar.xz
puppet-8d5ded09b9c9c944695c015e6e95b10ccebd6fb5.zip
Removing some code in Parameter that is unnecessary.
It's duplicated in Property, but was only ever called if the instance was Property -- in other words, the base class new about its subclass, but the subclass overrode that method any way. Signed-off-by: Luke Kanies <luke@madstop.com>
-rw-r--r--lib/puppet/parameter.rb5
-rw-r--r--lib/puppet/property.rb3
-rwxr-xr-xspec/unit/property.rb11
3 files changed, 13 insertions, 6 deletions
diff --git a/lib/puppet/parameter.rb b/lib/puppet/parameter.rb
index ef7f1c1ad..f90193fc8 100644
--- a/lib/puppet/parameter.rb
+++ b/lib/puppet/parameter.rb
@@ -419,11 +419,6 @@ class Puppet::Parameter
# late-binding (e.g., users might not exist when the value is assigned
# but might when it is asked for).
def value=(value)
- # If we're a parameter, just hand the processing off to the should
- # method.
- if self.is_a?(Puppet::Property)
- return self.should = value
- end
if respond_to?(:validate)
validate(value)
end
diff --git a/lib/puppet/property.rb b/lib/puppet/property.rb
index 913f43977..50a1b71de 100644
--- a/lib/puppet/property.rb
+++ b/lib/puppet/property.rb
@@ -446,7 +446,8 @@ class Property < Puppet::Parameter
self.should
end
- # Provide a common hook for setting @should, just like params.
+ # Match the Parameter interface, but we really just use 'should' internally.
+ # Note that the should= method does all of the validation and such.
def value=(value)
self.should = value
end
diff --git a/spec/unit/property.rb b/spec/unit/property.rb
index a562f8bb4..e5b1e0013 100755
--- a/spec/unit/property.rb
+++ b/spec/unit/property.rb
@@ -5,6 +5,17 @@ require File.dirname(__FILE__) + '/../spec_helper'
require 'puppet/property'
describe Puppet::Property do
+ describe "when setting the value" do
+ it "should just set the 'should' value" do
+ @class = Class.new(Puppet::Property)
+ @class.initvars
+ @property = @class.new :resource => mock('resource')
+
+ @property.expects(:should=).with("foo")
+ @property.value = "foo"
+ end
+ end
+
describe "when returning the value" do
before do
@class = Class.new(Puppet::Property)