From cd09d6b90d3365d06e8e706aab3edbd8f568f1c9 Mon Sep 17 00:00:00 2001 From: Luke Kanies Date: Tue, 11 Nov 2008 12:45:50 -0800 Subject: Refactoring the Cacher interface to always require attribute declaration. Previously you could dynamically use cached values, but the new interface requires a single static declaration of the attribute: cached_attr(:myattr) { my_init_code() } This is cleaner, because it makes it easy to turn the code into an init method and generally makes the whole thing easier to think about. Most of this commit is going through the different classes that already using the Caching engine. Signed-off-by: Luke Kanies --- lib/puppet/file_serving/mount.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'lib/puppet/file_serving/mount.rb') diff --git a/lib/puppet/file_serving/mount.rb b/lib/puppet/file_serving/mount.rb index c52cedbfb..552cf33f2 100644 --- a/lib/puppet/file_serving/mount.rb +++ b/lib/puppet/file_serving/mount.rb @@ -13,16 +13,17 @@ require 'puppet/file_serving/content' # or content objects. class Puppet::FileServing::Mount < Puppet::Network::AuthStore include Puppet::Util::Logging - extend Puppet::Util::Cacher - def self.localmap - attr_cache(:localmap) { + class << self + include Puppet::Util::Cacher + + cached_attr(:localmap) do { "h" => Facter.value("hostname"), "H" => [Facter.value("hostname"), Facter.value("domain")].join("."), "d" => Facter.value("domain") } - } + end end attr_reader :name -- cgit