Class: Rails::Hyperdrive::Tools::RunRuby

Inherits:
Base
  • Object
show all
Defined in:
lib/rails/hyperdrive/tools/run_ruby.rb

Constant Summary collapse

MAX_TIMEOUT_SECONDS =
120

Class Method Summary collapse

Methods inherited from Base

respond_error, respond_json, respond_text, with_dev_guard

Class Method Details

.call(code:, timeout: Rails::Hyperdrive::ConsoleExecutor::DEFAULT_TIMEOUT_SECONDS, server_context: nil) ⇒ Object



21
22
23
24
25
26
27
# File 'lib/rails/hyperdrive/tools/run_ruby.rb', line 21

def self.call(code:, timeout: Rails::Hyperdrive::ConsoleExecutor::DEFAULT_TIMEOUT_SECONDS, server_context: nil)
  with_dev_guard do
    t = [[timeout.to_i, 1].max, MAX_TIMEOUT_SECONDS].min
    result = Rails::Hyperdrive::ConsoleExecutor.eval(code, timeout: t)
    respond_json(result.to_h)
  end
end