module DBus::ObjectManager
A mixin for {DBus::Object} implementing {dbus.freedesktop.org/doc/dbus-specification.html#standard-interfaces-objectmanager org.freedesktop.DBus.ObjectManager}.
{ObjectServer#export} and {ObjectServer#unexport} will look for an ObjectManager parent in the path hierarchy. If found, it will emit InterfacesAdded or InterfacesRemoved, as appropriate.
Constants
- OBJECT_MANAGER_INTERFACE
Public Class Methods
Module#included, a hook for ‘include ObjectManager`, declares its dbus_interface.
# File lib/dbus/object_manager.rb 48 def self.included(base) 49 base.class_eval do 50 dbus_interface OBJECT_MANAGER_INTERFACE do 51 dbus_method :GetManagedObjects, "out res:a{oa{sa{sv}}}" do 52 [managed_objects] 53 end 54 55 dbus_signal :InterfacesAdded, "object:o, interfaces_and_properties:a{sa{sv}}" 56 dbus_signal :InterfacesRemoved, "object:o, interfaces:as" 57 end 58 end 59 end
Public Instance Methods
Implements ‘the GetManagedObjects` method. @return [Hash{ObjectPath => Hash{String => Hash{String => Data::Base}}}]
object -> interface -> property -> value
# File lib/dbus/object_manager.rb 26 def managed_objects 27 descendant_objects = object_server.descendants_for(path) 28 descendant_objects.each_with_object({}) do |obj, hash| 29 hash[obj.path] = obj.interfaces_and_properties 30 end 31 end
{ObjectServer#export} will call this for you to emit the ‘InterfacesAdded` signal. @param object [DBus::Object] @return [void]
# File lib/dbus/object_manager.rb 36 def object_added(object) 37 InterfacesAdded(object.path, object.interfaces_and_properties) 38 end
{ObjectServer#unexport} will call this for you to emit the ‘InterfacesRemoved` signal. @param object [DBus::Object] @return [void]
# File lib/dbus/object_manager.rb 43 def object_removed(object) 44 InterfacesRemoved(object.path, object.intfs.keys) 45 end