1
0
Fork 0
mirror of https://github.com/rails/execjs synced 2023-03-27 23:21:20 -04:00

fix from_environment

Addition to the https://github.com/rails/execjs/pull/5
I think it's better to use @const_defined?@
This commit is contained in:
Ivan Buiko 2015-04-09 18:26:41 +03:00
parent aca44d248c
commit 1d91177a03

View file

@ -55,15 +55,11 @@ module ExecJS
def self.from_environment
if name = ENV["EXECJS_RUNTIME"]
if runtime = const_get(name)
if runtime.available?
runtime if runtime.available?
else
raise RuntimeUnavailable, "#{runtime.name} runtime is not available on this system"
end
elsif !name.empty?
raise RuntimeUnavailable, "#{name} runtime is not defined"
end
raise RuntimeUnavailable, "#{name} runtime is not defined" unless const_defined?(name)
runtime = const_get(name)
raise RuntimeUnavailable, "#{runtime.name} runtime is not available on this system" unless runtime.available?
runtime
end
end