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
SOURCES_MANAGER_CONSTANT_WARNINGS = Set.new module SourcesManagerMissingConstant
SOURCES_MANAGER_CONSTANT_WARNINGS = Set.new
# Warn about deprecated use of `Pod::SourcesManager` and return the config's
# Source::Manager
#
# @return [Pod::Source::Manager]
#
def const_missing(const)
unless const.to_sym == :SourcesManager &&
ancestors.any? { |a| a == ::Pod || a.name.start_with?('Pod::') }
return super
end
# @!visibility private calling_line = caller.first
# if Pod::SourcesManagerMissingConstant::SOURCES_MANAGER_CONSTANT_WARNINGS.add?(calling_line)
# Warn about deprecated use of `Pod::SourcesManager` and return the config's warn 'Usage of the constant `Pod::SourcesManager` is deprecated, ' \
# Source::Manager 'use `Pod::Config.instance.sources_manager` instead ' \
# "(called from #{calling_line})"
# @return [Pod::Source::Manager] end
#
def self.sources_manager_constant Config.instance.sources_manager
calling_line = caller[1]
if SOURCES_MANAGER_CONSTANT_WARNINGS.add?(calling_line)
warn 'Usage of the constant `Pod::SourcesManager` is deprecated, ' \
'use `Pod::Config.instance.sources_manager` instead ' \
"(called from #{calling_line})"
end end
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) extend SourcesManagerMissingConstant
unless const.to_sym == :SourcesManager && ::Object.send(:extend, SourcesManagerMissingConstant)
ancestors.any? { |a| a == ::Pod || a.name.start_with?('Pod::') }
return super
end
::Pod.sources_manager_constant
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