Class: OpenHAB::Core::Items::Provider

Inherits:
Provider show all
Defined in:
lib/openhab/core/items/provider.rb

Overview

Provides Items created in Ruby to openHAB

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Provider

#[], #all, current, #inspect

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, #update!

Class Method Details

.registry ⇒ org.openhab.core.items.ItemRegistry

The Item registry



18
19
20
# File 'lib/openhab/core/items/provider.rb', line 18

def registry
  $ir
end

Instance Method Details

#remove(item_name, recursive = false) ⇒ Item?

Remove an item from this provider

Parameters:

  • item_name (String)
  • recursive (true, false) (defaults to: false)

Returns:

  • (Item, nil) —

    The removed item, if found.



30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/openhab/core/items/provider.rb', line 30

def remove(item_name, recursive = false) # rubocop:disable Style/OptionalBooleanParameter -- matches Java method
  DSL::Items::Builder::Persistence.synchronize do
    names = removal_names(item_name, recursive)
    result = nil
    begin
      names.each do |name|
        removed = super(name)
        result = removed if name == item_name
      end
      result
    ensure
      names.reject! { |name| self.class.registry.get(name) }
      DSL::Items::Builder::Persistence.remove(*names)
    end
  end
end