Commit c60a32aa authored by Samuel Giddins's avatar Samuel Giddins

[SourcesManager] Move const_missing override to its own module

parent 3f47ead7
...@@ -155,35 +155,31 @@ module Pod ...@@ -155,35 +155,31 @@ module Pod
end end
# @!visibility private # @!visibility private
module SourcesManagerMissingConstant
SOURCES_MANAGER_CONSTANT_WARNINGS = Set.new SOURCES_MANAGER_CONSTANT_WARNINGS = Set.new
# @!visibility private
#
# Warn about deprecated use of `Pod::SourcesManager` and return the config's # Warn about deprecated use of `Pod::SourcesManager` and return the config's
# Source::Manager # Source::Manager
# #
# @return [Pod::Source::Manager] # @return [Pod::Source::Manager]
# #
def self.sources_manager_constant def const_missing(const)
calling_line = caller[1] unless const.to_sym == :SourcesManager &&
if SOURCES_MANAGER_CONSTANT_WARNINGS.add?(calling_line) ancestors.any? { |a| a == ::Pod || a.name.start_with?('Pod::') }
return super
end
calling_line = caller.first
if Pod::SourcesManagerMissingConstant::SOURCES_MANAGER_CONSTANT_WARNINGS.add?(calling_line)
warn 'Usage of the constant `Pod::SourcesManager` is deprecated, ' \ warn 'Usage of the constant `Pod::SourcesManager` is deprecated, ' \
'use `Pod::Config.instance.sources_manager` instead ' \ 'use `Pod::Config.instance.sources_manager` instead ' \
"(called from #{calling_line})" "(called from #{calling_line})"
end end
Config.instance.sources_manager Config.instance.sources_manager
end end
end
def Pod.const_missing(const)
return super unless const.to_sym == :SourcesManager
::Pod.sources_manager_constant
end
def Object.const_missing(const)
unless const.to_sym == :SourcesManager &&
ancestors.any? { |a| a == ::Pod || a.name.start_with?('Pod::') }
return super
end end
::Pod.sources_manager_constant
extend SourcesManagerMissingConstant
::Object.send(:extend, SourcesManagerMissingConstant)
end end
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment