Module: RubyGaurden::Bridging
Instance Method Summary collapse
-
#call(method_name, *args) ⇒ Object
Directly invokes a Ruby method defined inside the sandbox.
-
#reset_io! ⇒ Object
Clears the IO buffers (stdout and stderr).
-
#stderr ⇒ Array<String>
Returns the accumulated stderr produced by the sandbox.
-
#stdout ⇒ Array<String>
Returns the accumulated stdout produced by the sandbox.
Instance Method Details
#call(method_name, *args) ⇒ Object
Directly invokes a Ruby method defined inside the sandbox. This bypasses the Ruby-to-JS compilation step for the call itself.
123 124 125 126 127 128 129 |
# File 'lib/ruby_gaurden/bridging.rb', line 123 def call(method_name, *args) # We use JSON to move data across the bridge to avoid V8/Ruby object mapping overhead # and to ensure Opal objects are correctly initialized. serialized_args = args.to_json result = context.call('__rb_bridge_invoke', method_name.to_s, serialized_args) handle_bridge_result(result) end |
#reset_io! ⇒ Object
Clears the IO buffers (stdout and stderr).
112 113 114 115 |
# File 'lib/ruby_gaurden/bridging.rb', line 112 def reset_io! @stdout = [] @stderr = [] end |
#stderr ⇒ Array<String>
Returns the accumulated stderr produced by the sandbox.
107 108 109 |
# File 'lib/ruby_gaurden/bridging.rb', line 107 def stderr @stderr ||= [] end |
#stdout ⇒ Array<String>
Returns the accumulated stdout produced by the sandbox.
101 102 103 |
# File 'lib/ruby_gaurden/bridging.rb', line 101 def stdout @stdout ||= [] end |