diff options
author | Jeff McCune <jeff@puppetlabs.com> | 2012-03-13 17:48:09 -0700 |
---|---|---|
committer | Jeff McCune <jeff@puppetlabs.com> | 2012-03-13 17:48:09 -0700 |
commit | 033eddadc2b3f72783056fe7c9d70f651bcdf857 (patch) | |
tree | 04a0d7b3b488e41c3f553695bfbf4ec12f703952 /lib/facter/util/puppet_settings.rb | |
parent | f74705d6215dc1e9ce0b055e11702b3ea20b9ca5 (diff) | |
parent | 6b8f9dd329b40e1598fffde540b7cd59ddae9c2e (diff) | |
download | puppet-stdlib-033eddadc2b3f72783056fe7c9d70f651bcdf857.tar.gz puppet-stdlib-033eddadc2b3f72783056fe7c9d70f651bcdf857.tar.bz2 |
Merge branch '2.3.x'
* 2.3.x:
Update CHANGELOG and Modulefile for 2.3.1
(#13091) Fix LoadError exception with puppet apply
Diffstat (limited to 'lib/facter/util/puppet_settings.rb')
-rw-r--r-- | lib/facter/util/puppet_settings.rb | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/lib/facter/util/puppet_settings.rb b/lib/facter/util/puppet_settings.rb index c8c8363..1ad9452 100644 --- a/lib/facter/util/puppet_settings.rb +++ b/lib/facter/util/puppet_settings.rb @@ -1,15 +1,19 @@ module Facter module Util module PuppetSettings - class << self - def with_puppet - begin - Module.const_get("Puppet") - rescue NameError - nil - else - yield - end + # This method is intended to provide a convenient way to evaluate a + # Facter code block only if Puppet is loaded. This is to account for the + # situation where the fact happens to be in the load path, but Puppet is + # not loaded for whatever reason. Perhaps the user is simply running + # facter without the --puppet flag and they happen to be working in a lib + # directory of a module. + def self.with_puppet + begin + Module.const_get("Puppet") + rescue NameError + nil + else + yield end end end |