Class PersistentLocalVariable

java.lang.Object
org.jruby.embed.variable.AbstractVariable
org.jruby.embed.variable.PersistentLocalVariable
All Implemented Interfaces:
BiVariable

public class PersistentLocalVariable extends AbstractVariable
An implementation of BiVariable for a persistent local variable. This type of a local variable survives over multiple evaluation.
  • Field Details

  • Constructor Details

    • PersistentLocalVariable

      private PersistentLocalVariable(RubyObject receiver, String name, Object... javaObjects)
    • PersistentLocalVariable

      PersistentLocalVariable(RubyObject origin, String name, IRubyObject irubyObject)
      A constructor used when persistent local variables are retrieved from Ruby.
      Parameters:
      name - the persistent local variable name
      irubyObject - Ruby local object
  • Method Details

    • getInstance

      public static BiVariable getInstance(RubyObject receiver, String name, Object... javaObject)
      Returns an instance of this class. This factory method is used when a persistent local variable is put in BiVariableMap.
      Parameters:
      runtime - Ruby runtime
      name - a variable name
      javaObject - Java object that should be assigned to.
      Returns:
      the instance of PersistentLocalVariable
    • getType

      public BiVariable.Type getType()
      Returns enum type of this variable defined in BiVariable.
      Returns:
      this enum type, BiVariable.Type.LocalVariable.
    • isValidName

      public static boolean isValidName(Object name)
      Returns true if the given name is a decent Ruby local variable. Unless returns false.
      Parameters:
      name - is a name to be checked.
      Returns:
      true if the given name is of a Ruby local variable.
    • retrieve

      public static void retrieve(RubyObject receiver, BiVariableMap vars)
      Retrieves local variables from Ruby after the evaluation. This retrieval doesn't depend on eager option. Local variables are always retrieved eagerly.
      Parameters:
      runtime - Ruby runtime
      receiver - receiver object returned when a script is evaluated.
      vars - map to save retrieved local variables.
    • inject

      public void inject()
      Injects a local variable value to a parsed Ruby script. This method is invoked during EvalUnit#run() is executed.
    • remove

      public void remove()
      Attempts to remove this variable from top self or receiver.