Module: OpenHAB::CoreExt::Gems::MethodSourceScriptPatch
- Defined in:
- lib/openhab/core_ext/gems/method_source.rb
Overview
Patches to the method_source gem
Instance Method Summary collapse
-
#lines_for(file_name, line = nil) ⇒ Object
Read source lines from openHAB UI scripts when target file is "".
Instance Method Details
#lines_for(file_name, line = nil) ⇒ Object
Read source lines from openHAB UI scripts when target file is "".
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
# File 'lib/openhab/core_ext/gems/method_source.rb', line 18 def lines_for(file_name, line = nil) if file_name == "<script>" && (uid = $ctx&.[]("ruleUID")) action = OpenHAB::DSL.rules[uid]&.actions&.find do |candidate| next unless candidate.type_uid == "script.ScriptAction" # The script identifier is the owning handler's engine UUID, not its action ID. factory = OpenHAB::Core::Rules.manager.get_module_handler_factory(candidate.type_uid) handler = factory&.get_handler(candidate, uid) handler&.engine_identifier == $scriptExtension.script_identifier end script = action&.configuration&.[]("script") return script.lines if script end super end |