Class: Syntropy::Module
- Inherits:
-
Object
- Object
- Syntropy::Module
- Defined in:
- lib/syntropy/module.rb
Instance Attribute Summary collapse
-
#__export_value__ ⇒ Object
readonly
Returns the value of attribute export_value.
Class Method Summary collapse
Instance Method Summary collapse
- #app(**env) ⇒ Object
- #export(v) ⇒ Object
- #import(ref) ⇒ Object
-
#initialize(**env) ⇒ Module
constructor
A new instance of Module.
- #page_list(ref) ⇒ Object
- #template(proc = nil, &block) ⇒ Object
Constructor Details
#initialize(**env) ⇒ Module
Returns a new instance of Module.
61 62 63 64 65 66 67 68 |
# File 'lib/syntropy/module.rb', line 61 def initialize(**env) @env = env @machine = env[:machine] @module_loader = env[:module_loader] @app = env[:app] @ref = env[:ref] singleton_class.const_set(:MODULE, self) end |
Instance Attribute Details
#__export_value__ ⇒ Object (readonly)
Returns the value of attribute export_value.
70 71 72 |
# File 'lib/syntropy/module.rb', line 70 def __export_value__ @__export_value__ end |
Class Method Details
.load(env, code) ⇒ Object
54 55 56 57 58 |
# File 'lib/syntropy/module.rb', line 54 def self.load(env, code) m = new(**env) m.instance_eval(code) m.__export_value__ end |
Instance Method Details
#app(**env) ⇒ Object
90 91 92 |
# File 'lib/syntropy/module.rb', line 90 def app(**env) Syntropy::App.new(**(@env.merge(env))) end |
#export(v) ⇒ Object
71 72 73 |
# File 'lib/syntropy/module.rb', line 71 def export(v) @__export_value__ = v end |
#import(ref) ⇒ Object
75 76 77 |
# File 'lib/syntropy/module.rb', line 75 def import(ref) @module_loader.load(ref) end |
#page_list(ref) ⇒ Object
86 87 88 |
# File 'lib/syntropy/module.rb', line 86 def page_list(ref) Syntropy.page_list(@env, ref) end |
#template(proc = nil, &block) ⇒ Object
79 80 81 82 83 84 |
# File 'lib/syntropy/module.rb', line 79 def template(proc = nil, &block) proc ||= block raise "No template block/proc given" if !proc P2::Template.new(proc) end |