Sha256: c72766093597b5ea525402ae813cde13f19d91c2692b52d4061f013fb0cc5ee7

Contents?: true

Size: 1.33 KB

Versions: 8

Compression:

Stored size: 1.33 KB

Contents

package sandbox;

import org.jruby.Profile;
import org.jruby.Ruby;
import org.jruby.RubyClass;
import org.jruby.RubyModule;
import org.jruby.anno.JRubyClass;
import org.jruby.anno.JRubyMethod;
import org.jruby.runtime.builtin.IRubyObject;

public class SandboxModule {
  /**
   * Create the Sandbox module and add it to the Ruby runtime.
   */
  public static RubyModule createSandboxModule(final Ruby runtime) {
    RubyModule mSandbox = runtime.defineModule("Sandbox");
    mSandbox.defineAnnotatedMethods(SandboxModule.class);

    RubyClass cObject = runtime.getObject();
    RubyClass cSandboxFull = mSandbox.defineClassUnder("Full", cObject, SandboxFull.FULL_ALLOCATOR);
    cSandboxFull.defineAnnotatedMethods(SandboxFull.class);
    RubyClass cStandardError = runtime.getStandardError();
    RubyClass cSandboxException = mSandbox.defineClassUnder("SandboxException", cStandardError, cStandardError.getAllocator());

    return mSandbox;
  }

  @JRubyClass(name="Sandbox::SandboxException", parent="StandardError")
  public static class SandboxException {}

  @JRubyMethod(name="current", meta=true)
  public static IRubyObject s_current(IRubyObject recv) {
    Profile prof = recv.getRuntime().getProfile();
    if (prof instanceof SandboxProfile) {
      return ((SandboxProfile) prof).getSandbox();
    }
    return recv.getRuntime().getNil();
  }
}

Version data entries

8 entries across 8 versions & 3 rubygems

Version Path
xplenty-jruby_sandbox-0.2.9-java ext/java/sandbox/SandboxModule.java
xplenty-jruby_sandbox-0.2.8-java ext/java/sandbox/SandboxModule.java
xplenty-jruby_sandbox-0.2.7-java ext/java/sandbox/SandboxModule.java
xplenty-jruby_sandbox-0.2.6-java ext/java/sandbox/SandboxModule.java
xplenty-jruby_sandbox-0.2.5-java ext/java/sandbox/SandboxModule.java
xplenty-jruby_sandbox-0.2.4-java ext/java/sandbox/SandboxModule.java
jruby_sandbox-0.2.3-java ext/java/sandbox/SandboxModule.java
jruby-safe-0.2.2-java ext/java/sandbox/SandboxModule.java