Class: OpenHAB::Core::Things::Registry
- Inherits:
- 
      Object
      
        - Object
- OpenHAB::Core::Things::Registry
 
- Includes:
- LazyArray
- Defined in:
- lib/openhab/core/things/registry.rb
Overview
Provides access to all openHAB things, and acts like an array.
Instance Method Summary collapse
- 
  
    
      #[](uid)  ⇒ Thing? 
    
    
      (also: #include?, #key?, #has_key?)
    
  
  
  
  
  
  
  
  
  
    Gets a specific Thing. 
- 
  
    
      #build(preferred_provider = nil, update: true) { ... } ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    Enter the Thing Builder DSL. 
- 
  
    
      #remove(thing_uid)  ⇒ Thing? 
    
    
  
  
  
  
  
  
  
  
  
    Remove a Thing. 
- 
  
    
      #to_a  ⇒ Array<Thing> 
    
    
  
  
  
  
  
  
  
  
  
    Explicit conversion to array. 
Methods included from LazyArray
#each, #method_missing, #to_ary
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!
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class OpenHAB::Core::LazyArray
Instance Method Details
#[](uid) ⇒ Thing? Also known as: include?, key?, has_key?
Gets a specific Thing
| 22 23 24 | # File 'lib/openhab/core/things/registry.rb', line 22 def [](uid) EntityLookup.lookup_thing(uid) end | 
#build(preferred_provider = nil, update: true) { ... } ⇒ Object
Enter the Thing Builder DSL.
| 51 52 53 | # File 'lib/openhab/core/things/registry.rb', line 51 def build(preferred_provider = nil, update: true, &block) DSL::Things::Builder.new(preferred_provider, update: update).instance_eval(&block) end | 
#remove(thing_uid) ⇒ Thing?
Remove a Thing.
The thing must be a managed thing (typically created by Ruby or in the UI).
| 62 63 64 65 66 67 68 69 70 71 72 73 74 75 | # File 'lib/openhab/core/things/registry.rb', line 62 def remove(thing_uid) thing_uid = thing.uid if thing_uid.is_a?(Thing) thing_uid = ThingUID.new(thing_uid) if thing_uid.is_a?(String) provider = Provider.registry.provider_for(thing_uid) unless provider.is_a?(org.openhab.core.common.registry.ManagedProvider) raise "Cannot remove thing #{thing_uid} from non-managed provider #{provider.inspect}" end Links::Provider.registry.providers.grep(ManagedProvider).each do |managed_provider| managed_provider.remove_links_for_thing(thing_uid) end provider.remove(thing_uid) end | 
 
          