Module: OpenHAB::Transform
- Defined in:
- lib/rspec/openhab/helpers.rb
Class Method Summary collapse
Class Method Details
.add_script(modules, script) ⇒ Object
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/rspec/openhab/helpers.rb', line 6 def add_script(modules, script) full_name = modules.join("/") name = modules.pop (@scripts ||= {})[full_name] = engine_factory.script_engine.compile(script) mod = modules.inject(self) { |m, n| m.const_get(n, false) } mod.singleton_class.define_method(name) do |input, **kwargs| Transform.send(:transform, full_name, input, kwargs) end end |