Class: DBus::ProxyService
- Defined in:
- lib/dbus/proxy_service.rb
Overview
Used by clients to represent a named service on the other side of the bus.
Formerly this class was intermixed with ObjectServer as Service.
Direct Known Subclasses
Instance Attribute Summary collapse
-
#connection ⇒ Connection
readonly
The connection we’re using.
-
#name ⇒ BusName?
readonly
Will be nil for a PeerConnection.
Attributes inherited from NodeTree
Instance Method Summary collapse
-
#[](path) ⇒ ProxyObject
Retrieves an object at the given path.
-
#exists? ⇒ Boolean
Determine whether the service name already exists.
-
#initialize(name, connection) ⇒ ProxyService
constructor
A new instance of ProxyService.
-
#introspect ⇒ Object
Perform an introspection on all the objects on the service (starting recursively from the root).
-
#object(path, api: ApiOptions::A0) ⇒ ProxyObject
Retrieves an object at the given path whose methods always return an array.
Methods inherited from NodeTree
Constructor Details
#initialize(name, connection) ⇒ ProxyService
Returns a new instance of ProxyService.
31 32 33 34 35 |
# File 'lib/dbus/proxy_service.rb', line 31 def initialize(name, connection) @name = BusName.new(name) @connection = connection super() end |
Instance Attribute Details
#connection ⇒ Connection (readonly)
Returns The connection we’re using.
28 29 30 |
# File 'lib/dbus/proxy_service.rb', line 28 def connection @connection end |
#name ⇒ BusName? (readonly)
Will be nil for a DBus::PeerConnection
26 27 28 |
# File 'lib/dbus/proxy_service.rb', line 26 def name @name end |
Instance Method Details
#[](path) ⇒ ProxyObject
Retrieves an object at the given path.
55 56 57 |
# File 'lib/dbus/proxy_service.rb', line 55 def [](path) object(path, api: ApiOptions::A1) end |
#exists? ⇒ Boolean
Determine whether the service name already exists.
38 39 40 41 |
# File 'lib/dbus/proxy_service.rb', line 38 def exists? bus = connection # TODO: raise a better error if this is a peer connection bus.proxy.ListNames[0].member?(@name) end |
#introspect ⇒ Object
Perform an introspection on all the objects on the service (starting recursively from the root).
45 46 47 48 49 50 |
# File 'lib/dbus/proxy_service.rb', line 45 def introspect raise NotImplementedError if block_given? rec_introspect(@root, "/") self end |
#object(path, api: ApiOptions::A0) ⇒ ProxyObject
Retrieves an object at the given path whose methods always return an array.
64 65 66 67 68 69 70 71 72 73 |
# File 'lib/dbus/proxy_service.rb', line 64 def object(path, api: ApiOptions::A0) node = get_node(path, create: true) if node.object.nil? || node.object.api != api node.object = ProxyObject.new( @connection, @name, path, api: api ) end node.object end |