Class: Syntropy::ModuleContext
- Inherits:
-
Object
- Object
- Syntropy::ModuleContext
- Defined in:
- lib/syntropy/module_loader.rb
Overview
The Syntropy::ModuleContext class provides a context for loading a module. A
module is a .rb source file that implements a route endpoint, a template,
utility methods or any other functionality needed by the web app.
The following instance variables are available to modules:
@env: the app environment hash@machine: a reference to the UringMachine instance@module_loader: a reference to the module loader@app: a reference to the app@ref: the module's logical path (path relative to the app root)@logger: a reference to the app's logger
In addition, the module code also has access to the MODULE constant which
is set to self, and may be used to refer to various methods defined in the
module.
Instance Attribute Summary collapse
-
#__dependencies__ ⇒ Object
readonly
Returns the value of attribute dependencies.
-
#__export_value__ ⇒ Object
readonly
Returns the value of attribute export_value.
Instance Method Summary collapse
-
#collection_module? ⇒ bool
Returns true if the module is a collection module.
-
#initialize(env, code, fn, extensions) ⇒ void
constructor
Initializes a module with the given environment hash.
Constructor Details
#initialize(env, code, fn, extensions) ⇒ void
Initializes a module with the given environment hash.
267 268 269 270 271 272 273 274 275 276 277 278 279 |
# File 'lib/syntropy/module_loader.rb', line 267 def initialize(env, code, fn, extensions) @env = env @machine = env[:machine] @module_loader = env[:module_loader] @app = env[:app] @ref = env[:ref] @logger = env[:logger] @__dependencies__ = [] singleton_class.const_set(:MODULE, self) apply_extensions(extensions) instance_eval(code, fn) end |
Instance Attribute Details
#__dependencies__ ⇒ Object (readonly)
Returns the value of attribute dependencies.
281 282 283 |
# File 'lib/syntropy/module_loader.rb', line 281 def __dependencies__ @__dependencies__ end |
#__export_value__ ⇒ Object (readonly)
Returns the value of attribute export_value.
281 282 283 |
# File 'lib/syntropy/module_loader.rb', line 281 def __export_value__ @__export_value__ end |
Instance Method Details
#collection_module? ⇒ bool
Returns true if the module is a collection module. See also #collection_module!
287 288 289 |
# File 'lib/syntropy/module_loader.rb', line 287 def collection_module? @collection_module_p end |