Module: WrapInModule::Script::ScriptModuleMethods
- Defined in:
- lib/wrap_in_module.rb
Overview
def to_s # :nodoc:
"#<#{self.class}:#{File.join(__dir, File.basename(__main_file))}>"
end
Instance Attribute Summary collapse
-
#__script_scope ⇒ Object
readonly
Returns the value of attribute __script_scope.
Instance Method Summary collapse
-
#__local_variable_get(name) ⇒ Object
Gets value of local var in the script.
-
#__local_variables ⇒ Object
Gets list of local vars in the script.
-
#method_added(name) ⇒ Object
This is so that
def meth...behaves like in Ruby’s top-level context.
Instance Attribute Details
#__script_scope ⇒ Object (readonly)
Returns the value of attribute __script_scope.
121 122 123 |
# File 'lib/wrap_in_module.rb', line 121 def __script_scope @__script_scope end |
Instance Method Details
#__local_variable_get(name) ⇒ Object
Gets value of local var in the script. Does not see local vars in files loaded or required by that script.
131 132 133 |
# File 'lib/wrap_in_module.rb', line 131 def __local_variable_get(name) eval(name.to_s, __script_scope) end |
#__local_variables ⇒ Object
Gets list of local vars in the script. Does not see local vars in files loaded or required by that script.
125 126 127 |
# File 'lib/wrap_in_module.rb', line 125 def __local_variables eval("local_variables", __script_scope) end |
#method_added(name) ⇒ Object
This is so that def meth... behaves like in Ruby’s top-level context. The implementation simply calls Module#module_function(name).
117 118 119 |
# File 'lib/wrap_in_module.rb', line 117 def method_added(name) # :nodoc: module_function(name) end |