Skip to content
Snippets Groups Projects
Commit b1120dd4 authored by Caleb Xu's avatar Caleb Xu
Browse files

extract: check if DependencyCollector::Compat is defined before monkey-patch

parent ad0f9d60
No related branches found
No related tags found
No related merge requests found
......@@ -44,11 +44,13 @@ def with_monkey_patch
define_method(:parse_symbol_spec) { |*| }
end
DependencyCollector::Compat.class_eval do
if method_defined?(:parse_string_spec)
alias_method :old_parse_string_spec, :parse_string_spec
if defined?(DependencyCollector::Compat)
DependencyCollector::Compat.class_eval do
if method_defined?(:parse_string_spec)
alias_method :old_parse_string_spec, :parse_string_spec
end
define_method(:parse_string_spec) { |*| }
end
define_method(:parse_string_spec) { |*| }
end
yield
......@@ -81,10 +83,12 @@ ensure
end
end
DependencyCollector::Compat.class_eval do
if method_defined?(:old_parse_string_spec)
alias_method :parse_string_spec, :old_parse_string_spec
undef :old_parse_string_spec
if defined?(DependencyCollector::Compat)
DependencyCollector::Compat.class_eval do
if method_defined?(:old_parse_string_spec)
alias_method :parse_string_spec, :old_parse_string_spec
undef :old_parse_string_spec
end
end
end
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment