module ChefCompat::Monkeypatches::Chef::Resource::LWRPBase
Public Instance Methods
build_from_file(cookbook_name, filename, run_context)
click to toggle source
Calls superclass method
# File files/lib/chef_compat/monkeypatches/chef/resource/lwrp_base.rb, line 20 def build_from_file(cookbook_name, filename, run_context) # If the cookbook this LWRP is from depends on compat_resource, fix its LWRPs up real good if run_context.cookbook_collection[cookbook_name].metadata.dependencies.has_key?('compat_resource') # All cookbooks do Class.new(Chef::Resource::LWRPBase). Change Class.new # temporarily to translate Chef::Resource::LWRPBase to ChefCompat::Resource ChefCompat::Monkeypatches::Class.module_eval do def new(*args, &block) # Trick it! Use ChefCompat::Resource instead of Chef::Resource::LWRPBase if args == [ ::Chef::Resource::LWRPBase ] ChefCompat::Monkeypatches::Class.module_eval do remove_method(:new) if method_defined?(:new) end args = [ ChefCompat::Resource::LWRPBase ] end super(*args, &block) end end begin # Call the actual build_from_file super ensure class<<ChefCompat::Monkeypatches::Class remove_method(:new) if method_defined?(:new) end end else # Call the actual build_from_file super end end
new(*args, &block)
click to toggle source
Calls superclass method
# File files/lib/chef_compat/monkeypatches/chef/resource/lwrp_base.rb, line 26 def new(*args, &block) # Trick it! Use ChefCompat::Resource instead of Chef::Resource::LWRPBase if args == [ ::Chef::Resource::LWRPBase ] ChefCompat::Monkeypatches::Class.module_eval do remove_method(:new) if method_defined?(:new) end args = [ ChefCompat::Resource::LWRPBase ] end super(*args, &block) end