Class: DBus::ProxyObjectFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/dbus/proxy_object_factory.rb

Overview

D-Bus proxy object factory class

Class that generates and sets up a proxy object based on introspection data.

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(xml, bus, dest, path, api: ApiOptions::CURRENT) ⇒ ProxyObjectFactory

Creates a new proxy object factory for the given introspection XML xml, bus, destination dest, and path.



19
20
21
22
23
24
25
# File 'lib/dbus/proxy_object_factory.rb', line 19

def initialize(xml, bus, dest, path, api: ApiOptions::CURRENT)
  @xml = xml
  @bus = bus
  @path = path
  @dest = dest
  @api = api
end

Class Method Details

.introspect_into(pobj, xml) ⇒ Object

Investigates the sub-nodes of the proxy object pobj based on the introspection XML data xml and sets them up recursively.

Parameters:



31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/dbus/proxy_object_factory.rb', line 31

def self.introspect_into(pobj, xml)
  # intfs [Array<Interface>], subnodes [Array<String>]
  intfs, pobj.subnodes = IntrospectXMLParser.new(xml).parse
  intfs.each do |i|
    poi = ProxyObjectInterface.new(pobj, i.name)
    i.methods.each_value { |m| poi.define(m) }
    i.signals.each_value { |s| poi.define(s) }
    i.properties.each_value { |p| poi.define(p) }
    pobj[i.name] = poi
  end
  pobj.introspected = true
end

Instance Method Details

#buildObject

Generates, sets up and returns the proxy object.



45
46
47
48
49
# File 'lib/dbus/proxy_object_factory.rb', line 45

def build
  po = ProxyObject.new(@bus, @dest, @path, api: @api)
  ProxyObjectFactory.introspect_into(po, @xml)
  po
end