diff options
| -rw-r--r-- | lib/puppet/util/cacher.rb | 1 | ||||
| -rwxr-xr-x | spec/unit/util/cacher.rb | 9 |
2 files changed, 10 insertions, 0 deletions
diff --git a/lib/puppet/util/cacher.rb b/lib/puppet/util/cacher.rb index ef619c9a6..e42577686 100644 --- a/lib/puppet/util/cacher.rb +++ b/lib/puppet/util/cacher.rb @@ -116,6 +116,7 @@ module Puppet::Util::Cacher end def expired_by_ttl?(name) + return false unless self.class.respond_to?(:attr_ttl) return false unless ttl = self.class.attr_ttl(name) @ttl_timestamps ||= {} diff --git a/spec/unit/util/cacher.rb b/spec/unit/util/cacher.rb index 696ef6b19..d0f5d5e92 100755 --- a/spec/unit/util/cacher.rb +++ b/spec/unit/util/cacher.rb @@ -149,6 +149,15 @@ describe Puppet::Util::Cacher do lambda { klass.cached_attr(:myattr, :ttl => "yep") { Time.now } }.should raise_error(ArgumentError) end + it "should not check for a ttl expiration if the class does not support that method" do + klass = Class.new do + extend Puppet::Util::Cacher + end + + klass.metaclass.cached_attr(:myattr) { "eh" } + klass.myattr + end + it "should automatically expire cached attributes whose ttl has expired, even if no expirer is present" do klass = Class.new do def self.to_s |
