summaryrefslogtreecommitdiff
path: root/lib/rbconfig/obsolete.rb
blob: 7025fb43fb73b6d2e7ac2101fb3233fed053b2b9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
module ::RbConfig
  module Obsolete
  end
  class << Obsolete
    def _warn_
      loc, = caller_locations(2, 1)
      loc = "#{loc.to_s}: " if loc
      warn "#{loc}Use RbConfig instead of obsolete and deprecated Config."
      self
    end

    def const_missing(name)
      _warn_
      ::RbConfig.const_get(name)
    end

    def method_missing(*args, &block)
      _warn_
      rbconfig = ::RbConfig
      result = rbconfig.__send__(*args, &block)
      result = rbconfig if rbconfig.equal?(result)
      result
    end

    def respond_to_missing?(*args, &block)
      _warn_
      ::RbConfig.send(:respond_to_missing?, *args, &block)
    end
  end
end

::Config = ::RbConfig::Obsolete._warn_
=begin
def Object.const_missing(name)
  return super unless name == :Config
  ::RbConfig::Obsolete._warn_
end
=end