diff options
author | danielsdeleo <dan@opscode.com> | 2013-01-04 16:41:37 -0800 |
---|---|---|
committer | danielsdeleo <dan@opscode.com> | 2013-01-04 16:41:37 -0800 |
commit | 40115a8debbf739ada4087115d0fabc4e6e64426 (patch) | |
tree | fe0c24bbbc3136960f98a19241eec22296fdafec | |
parent | e0f3a2c5051256659ec0663517be791abaaa28ac (diff) | |
download | chef-40115a8debbf739ada4087115d0fabc4e6e64426.tar.gz |
Fix dynamic inclusion of windows securable behavior
-rw-r--r-- | lib/chef/mixin/securable.rb | 28 | ||||
-rw-r--r-- | spec/unit/mixin/securable_spec.rb | 8 |
2 files changed, 19 insertions, 17 deletions
diff --git a/lib/chef/mixin/securable.rb b/lib/chef/mixin/securable.rb index 4ab343df8f..f77703f21a 100644 --- a/lib/chef/mixin/securable.rb +++ b/lib/chef/mixin/securable.rb @@ -171,21 +171,10 @@ class Chef end #==WindowsSecurableAttributes - # Defines methods #rights, #deny_rights, and #inherits to describe - # Windows file security ACLs on the including class. The including class - # is also extended with WindowsMacros, so more rights attributes may be - # defined. + # Defines #inherits to describe Windows file security ACLs on the + # including class module WindowsSecurableAttributes - # Callback that fires when included; will extend the including class - # with WindowsMacros and define #rights and #deny_rights on it. - def self.included(including_class) - including_class.extend(WindowsMacros) - - # create a default 'rights' attribute - including_class.rights_attribute(:rights) - including_class.rights_attribute(:deny_rights) - end def inherits(arg=nil) set_or_return( @@ -198,7 +187,18 @@ class Chef if RUBY_PLATFORM =~ /mswin|mingw|windows/ include WindowsSecurableAttributes - end # Windows-specific + end + + # Callback that fires when included; will extend the including class + # with WindowsMacros and define #rights and #deny_rights on it. + def self.included(including_class) + if RUBY_PLATFORM =~ /mswin|mingw|windows/ + including_class.extend(WindowsMacros) + # create a default 'rights' attribute + including_class.rights_attribute(:rights) + including_class.rights_attribute(:deny_rights) + end + end end end diff --git a/spec/unit/mixin/securable_spec.rb b/spec/unit/mixin/securable_spec.rb index d2e8770c9d..764da9b1d1 100644 --- a/spec/unit/mixin/securable_spec.rb +++ b/spec/unit/mixin/securable_spec.rb @@ -112,9 +112,11 @@ describe Chef::Mixin::Securable do @original_config = Chef::Config.hash_dup load File.join(File.dirname(__FILE__), "..", "..", "..", "lib", "chef", "config.rb") load File.join(File.dirname(__FILE__), "..", "..", "..", "lib", "chef", "mixin", "securable.rb") - @securable = Object.new - @securable.send(:extend, Chef::Mixin::Securable) - @securable.send(:extend, Chef::Mixin::ParamsValidate) + SECURABLE_CLASS = Class.new do + include Chef::Mixin::Securable + include Chef::Mixin::ParamsValidate + end + @securable = SECURABLE_CLASS.new end end |