mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Search subclasses from constants
This commit is contained in:
parent
a7dda449e8
commit
4e32a4ab81
Notes:
git
2021-02-22 13:24:48 +09:00
1 changed files with 3 additions and 6 deletions
|
@ -9,14 +9,11 @@ end
|
||||||
class Exports
|
class Exports
|
||||||
PrivateNames = /(?:Init_|InitVM_|ruby_static_id_|threadptr|_ec_|DllMain\b)/
|
PrivateNames = /(?:Init_|InitVM_|ruby_static_id_|threadptr|_ec_|DllMain\b)/
|
||||||
|
|
||||||
@@subclass = []
|
|
||||||
def self.inherited(klass)
|
|
||||||
@@subclass << [/#{klass.name.sub(/.*::/, '').downcase}/i, klass]
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.create(*args, &block)
|
def self.create(*args, &block)
|
||||||
platform = RUBY_PLATFORM
|
platform = RUBY_PLATFORM
|
||||||
pat, klass = @@subclass.find {|p, k| p =~ platform}
|
klass = constants.find do |p|
|
||||||
|
break const_get(p) if platform.include?(p.to_s.downcase)
|
||||||
|
end
|
||||||
unless klass
|
unless klass
|
||||||
raise ArgumentError, "unsupported platform: #{platform}"
|
raise ArgumentError, "unsupported platform: #{platform}"
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue