Class: XmlRPCBase
- Inherits:
-
Object
- Object
- XmlRPCBase
- Defined in:
- lib/o3d3xx/xml_rpc_base.rb
Direct Known Subclasses
O3D3XX::ApplicationProxy, O3D3XX::DeviceProxy, O3D3XX::EditProxy, O3D3XX::ImagerProxy, O3D3XX::NetworkProxy, O3D3XX::O3D3xxProxy, O3D3XX::SessionProxy
Instance Attribute Summary collapse
-
#rpc_cl ⇒ Object
readonly
Returns the value of attribute rpc_cl.
Instance Method Summary collapse
-
#dump ⇒ Object
Dumps configuration.
-
#getConfig ⇒ Object
Returns configuration object.
-
#initialize(settings = {}) ⇒ XmlRPCBase
constructor
Initializes XMLRPC connection.
-
#method_missing(meth, *args) ⇒ Object
Calls any method via xmlrpc.
Constructor Details
#initialize(settings = {}) ⇒ XmlRPCBase
Initializes XMLRPC connection. Needs connection and Request parameters via given settings hash
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/o3d3xx/xml_rpc_base.rb', line 26 def initialize(settings={}) raise 'No host name given !' if settings[:host].nil? raise 'No port given !' if settings[:port].nil? raise 'No endpoint given !' if settings[:path].nil? @config = { :host => settings[:host], :port => settings[:port], :path => '/api/rpc/v1/' + settings[:path] } @rpc_cl = XMLRPC::Client.new(@config[:host], @config[:path], @config[:port], nil, nil, nil, nil, nil, 20) # 20 seconds connection timeout #dump end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method
#method_missing(meth, *args) ⇒ Object
Calls any method via xmlrpc
45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/o3d3xx/xml_rpc_base.rb', line 45 def method_missing(meth, *args) arg = args begin @rpc_cl.call_async(meth.to_s, *arg) rescue XMLRPC::FaultException => e if e..include? 'method not found' super else raise end end end |
Instance Attribute Details
#rpc_cl ⇒ Object (readonly)
Returns the value of attribute rpc_cl.
19 20 21 |
# File 'lib/o3d3xx/xml_rpc_base.rb', line 19 def rpc_cl @rpc_cl end |
Instance Method Details
#dump ⇒ Object
Dumps configuration
66 67 68 69 70 |
# File 'lib/o3d3xx/xml_rpc_base.rb', line 66 def dump puts "Host: #{@config[:host]}" puts "Port: #{@config[:port]}" puts "URL : #{@config[:path]}" end |
#getConfig ⇒ Object
Returns configuration object
60 61 62 |
# File 'lib/o3d3xx/xml_rpc_base.rb', line 60 def getConfig return @config end |