Class: OpenHAB::Core::Sitemaps::Provider
- Defined in:
- lib/openhab/core/sitemaps/provider.rb
Overview
Provides sitemaps created in Ruby to openHAB
Instance Method Summary collapse
-
#build(update: true) { ... } ⇒ void
Enter the Sitemap Builder DSL.
-
#remove(sitemap) ⇒ Boolean
Remove a sitemap.
-
#update(sitemap) ⇒ void
Notify listeners about updated sitemap.
Methods inherited from Provider
Methods included from Enumerable
#all_groups, #all_members, #command, #command!, #decrease, #down, #equipments, #fast_forward, #groups, #increase, #locations, #member_of, #members, #move, #next, #not_member_of, #not_tagged, #off, #on, #pause, #play, #points, #previous, #refresh, #rewind, #stop, #tagged, #toggle, #up, #update!
Instance Method Details
#build(update: true) { ... } ⇒ void
This method returns an undefined value.
Enter the Sitemap Builder DSL.
131 132 133 134 135 136 137 138 139 140 141 142 |
# File 'lib/openhab/core/sitemaps/provider.rb', line 131 def build(update: true, &block) builder_proxy = SimpleDelegator.new(nil) if block.arity == 1 builder = DSL::Sitemaps::Builder.new(self, builder_proxy, update: update) if block.arity == 1 builder_proxy.__setobj__(builder) DSL::ThreadLocal.thread_local(openhab_create_dummy_items: true) do yield builder_proxy end else builder.instance_eval(&block) end end |
#remove(sitemap) ⇒ Boolean
Remove a sitemap.
165 166 167 168 |
# File 'lib/openhab/core/sitemaps/provider.rb', line 165 def remove(sitemap) sitemap = sitemap.uid if sitemap.respond_to?(:uid) super end |
#update(sitemap) ⇒ void
This method returns an undefined value.
Notify listeners about updated sitemap
150 151 152 153 154 155 156 157 |
# File 'lib/openhab/core/sitemaps/provider.rb', line 150 def update(sitemap) if sitemap.respond_to?(:to_str) sitemap = get(sitemap).tap do |obj| raise ArgumentError, "Sitemap #{sitemap} not found" unless obj end end super end |