Class: CommonJS::Module
- Inherits:
-
Object
- Object
- CommonJS::Module
- Defined in:
- lib/commonjs/module.rb
Defined Under Namespace
Classes: Native
Instance Attribute Summary collapse
-
#exports ⇒ Object
Returns the value of attribute exports.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
Instance Method Summary collapse
-
#initialize(id, env) ⇒ Module
constructor
A new instance of Module.
- #require_function ⇒ Object
Constructor Details
#initialize(id, env) ⇒ Module
Returns a new instance of Module.
7 8 9 10 11 12 |
# File 'lib/commonjs/module.rb', line 7 def initialize(id, env) @id = id @env = env @exports = env.new_object @segments = id.split('/') end |
Instance Attribute Details
#exports ⇒ Object
Returns the value of attribute exports.
5 6 7 |
# File 'lib/commonjs/module.rb', line 5 def exports @exports end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
4 5 6 |
# File 'lib/commonjs/module.rb', line 4 def id @id end |
Instance Method Details
#require_function ⇒ Object
14 15 16 17 18 19 20 |
# File 'lib/commonjs/module.rb', line 14 def require_function @require_function ||= lambda do |*args| this, module_id = *args module_id ||= this #backwards compatibility with TRR < 0.10 @env.require((module_id)) end end |