diff options
Diffstat (limited to 'lib/puppet/util/monkey_patches.rb')
-rw-r--r-- | lib/puppet/util/monkey_patches.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/puppet/util/monkey_patches.rb b/lib/puppet/util/monkey_patches.rb index bdce5ec1d..1c35ae523 100644 --- a/lib/puppet/util/monkey_patches.rb +++ b/lib/puppet/util/monkey_patches.rb @@ -48,6 +48,7 @@ if RUBY_VERSION == '1.8.7' end end + class Object # ActiveSupport 2.3.x mixes in a dangerous method # that can cause rspec to fork bomb @@ -56,3 +57,17 @@ class Object raise NotImplementedError, "Kernel.daemonize is too dangerous, please don't try to use it." end end + +# Workaround for yaml_initialize, which isn't supported before Ruby +# 1.8.3. +if RUBY_VERSION == '1.8.1' || RUBY_VERSION == '1.8.2' + YAML.add_ruby_type( /^object/ ) { |tag, val| + type, obj_class = YAML.read_type_class( tag, Object ) + r = YAML.object_maker( obj_class, val ) + if r.respond_to? :yaml_initialize + r.instance_eval { instance_variables.each { |name| remove_instance_variable name } } + r.yaml_initialize(tag, val) + end + r + } +end |