Package org.jruby.embed.variable
Class PersistentLocalVariable
java.lang.Object
org.jruby.embed.variable.AbstractVariable
org.jruby.embed.variable.PersistentLocalVariable
- All Implemented Interfaces:
BiVariable
An implementation of BiVariable for a persistent local variable. This type of
a local variable survives over multiple evaluation.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.jruby.embed.variable.BiVariable
BiVariable.Type -
Field Summary
FieldsFields inherited from class org.jruby.embed.variable.AbstractVariable
fromRuby, javaObject, javaType, name, receiver, rubyObject -
Constructor Summary
ConstructorsModifierConstructorDescriptionprivatePersistentLocalVariable(RubyObject receiver, String name, Object... javaObjects) (package private)PersistentLocalVariable(RubyObject origin, String name, IRubyObject irubyObject) A constructor used when persistent local variables are retrieved from Ruby. -
Method Summary
Modifier and TypeMethodDescriptionstatic BiVariablegetInstance(RubyObject receiver, String name, Object... javaObject) Returns an instance of this class.getType()Returns enum type of this variable defined inBiVariable.voidinject()Injects a local variable value to a parsed Ruby script.static booleanisValidName(Object name) Returns true if the given name is a decent Ruby local variable.voidremove()Attempts to remove this variable from top self or receiver.static voidretrieve(RubyObject receiver, BiVariableMap vars) Retrieves local variables from Ruby after the evaluation.Methods inherited from class org.jruby.embed.variable.AbstractVariable
getCurrentContext, getJavaObject, getName, getReceiver, getRubyClass, getRubyObject, getRuntime, getTopSelf, getTopSelf, isReceiverIdentical, isValidName, setJavaObject, setRubyObject, updateByJavaObject, updateRubyObject
-
Field Details
-
VALID_NAME
- See Also:
-
-
Constructor Details
-
PersistentLocalVariable
-
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 nameirubyObject- Ruby local object
-
-
Method Details
-
getInstance
Returns an instance of this class. This factory method is used when a persistent local variable is put inBiVariableMap.- Parameters:
runtime- Ruby runtimename- a variable namejavaObject- Java object that should be assigned to.- Returns:
- the instance of PersistentLocalVariable
-
getType
Returns enum type of this variable defined inBiVariable.- Returns:
- this enum type, BiVariable.Type.LocalVariable.
-
isValidName
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
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 runtimereceiver- 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.
-