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:
parent
aca44d248c
commit
1d91177a03
1 changed files with 5 additions and 9 deletions
|
@ -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
|
||||
|
||||
|
|
Loading…
Reference in a new issue