Module: OpenHAB::Core::ScriptHandling
- Included in:
- DSL
- Defined in:
- lib/openhab/core/script_handling.rb
Overview
Provide callback mechanisms for script handling
Class Method Summary collapse
-
.script_loaded(&block) ⇒ void
Add a block of code to be executed once the rule script has finished loading.
-
.script_unloaded(priority: nil, &block) ⇒ void
Add a block of code to be executed when the script is unloaded.
Class Method Details
.script_loaded(&block) ⇒ void
This method returns an undefined value.
Add a block of code to be executed once the rule script has finished loading.
This can occur on openHAB start up, when the script is first created, or updated.
Multiple hooks can be added by calling #script_loaded multiple times. They can be used to perform final initializations.
31 32 33 |
# File 'lib/openhab/core/script_handling.rb', line 31 def script_loaded(&block) ScriptHandlingCallbacks.script_loaded_hooks << block end |
.script_unloaded(priority: nil, &block) ⇒ void
This method returns an undefined value.
Add a block of code to be executed when the script is unloaded.
This can occur when openHAB shuts down, or when the script is being reloaded.
Multiple hooks can be added by calling #script_unloaded multiple times. They can be used to perform final cleanup.
54 55 56 |
# File 'lib/openhab/core/script_handling.rb', line 54 def script_unloaded(priority: nil, &block) ScriptHandlingCallbacks.script_unloaded_hooks[priority || 0] << block end |