Class: Klenod::Runtime::Mod
- Inherits:
-
Module
- Object
- Module
- Klenod::Runtime::Mod
- Defined in:
- lib/klenod/runtime/mod.rb
Defined Under Namespace
Classes: Exports
Instance Attribute Summary collapse
-
#constant_name ⇒ Object
readonly
Returns the value of attribute constant_name.
-
#eval_path ⇒ Object
readonly
Returns the value of attribute eval_path.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#source ⇒ Object
readonly
Returns the value of attribute source.
-
#source_map ⇒ Object
readonly
Returns the value of attribute source_map.
-
#version ⇒ Object
readonly
Returns the value of attribute version.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(path, source, imports: {}, source_map: nil, version: 0, constant_name: nil, eval_path: nil) ⇒ Mod
constructor
A new instance of Mod.
- #inspect ⇒ Object
- #marshal_dump ⇒ Object
- #marshal_load(data) ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(path, source, imports: {}, source_map: nil, version: 0, constant_name: nil, eval_path: nil) ⇒ Mod
Returns a new instance of Mod.
68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/klenod/runtime/mod.rb', line 68 def initialize(path, source, imports: {}, source_map: nil, version: 0, constant_name: nil, eval_path: nil) @path = path @source = source @imports = imports @source_map = source_map @version = version @constant_name = constant_name || self.class.constant_name_for(path) @eval_path = eval_path || path register_constant create_exports end |
Instance Attribute Details
#constant_name ⇒ Object (readonly)
Returns the value of attribute constant_name.
58 59 60 |
# File 'lib/klenod/runtime/mod.rb', line 58 def constant_name @constant_name end |
#eval_path ⇒ Object (readonly)
Returns the value of attribute eval_path.
58 59 60 |
# File 'lib/klenod/runtime/mod.rb', line 58 def eval_path @eval_path end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
58 59 60 |
# File 'lib/klenod/runtime/mod.rb', line 58 def path @path end |
#source ⇒ Object (readonly)
Returns the value of attribute source.
58 59 60 |
# File 'lib/klenod/runtime/mod.rb', line 58 def source @source end |
#source_map ⇒ Object (readonly)
Returns the value of attribute source_map.
58 59 60 |
# File 'lib/klenod/runtime/mod.rb', line 58 def source_map @source_map end |
#version ⇒ Object (readonly)
Returns the value of attribute version.
58 59 60 |
# File 'lib/klenod/runtime/mod.rb', line 58 def version @version end |
Class Method Details
.constant_name_for(path) ⇒ Object
60 61 62 |
# File 'lib/klenod/runtime/mod.rb', line 60 def self.constant_name_for(path) "Mod_#{Digest::SHA256.hexdigest(path)[0, 24]}" end |
Instance Method Details
#inspect ⇒ Object
64 65 66 |
# File 'lib/klenod/runtime/mod.rb', line 64 def inspect "Mod(#{path.inspect})" end |
#marshal_dump ⇒ Object
80 81 82 |
# File 'lib/klenod/runtime/mod.rb', line 80 def marshal_dump [@path, @source, @source_map, @version, @constant_name, @eval_path] end |
#marshal_load(data) ⇒ Object
84 85 86 87 88 89 90 |
# File 'lib/klenod/runtime/mod.rb', line 84 def marshal_load(data) @path, @source, @source_map, @version, @constant_name, @eval_path = data @eval_path ||= @path @imports = {} register_constant create_exports end |
#to_s ⇒ Object
92 93 94 |
# File 'lib/klenod/runtime/mod.rb', line 92 def to_s "#<#{self.class.name} path=#{@path.inspect}>" end |