mirror of
https://git.deluge-torrent.org/deluge
synced 2025-08-10 10:28:39 +00:00
update to allow for passing in a methods list when initialising
This commit is contained in:
parent
911d95815f
commit
b6dee74dd5
1 changed files with 31 additions and 17 deletions
|
@ -52,7 +52,22 @@ JSON.RPC = new Class({
|
||||||
this.setOptions(options)
|
this.setOptions(options)
|
||||||
this.url = url
|
this.url = url
|
||||||
if (this.options.methods.length == 0) {
|
if (this.options.methods.length == 0) {
|
||||||
var methodNames = this._execute('system.listMethods', {async: false});
|
this._setMethods(this._execute('system.listMethods', {async: false}));
|
||||||
|
} else {
|
||||||
|
this._setMethods(this.options.methods);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
Property: _setMethods
|
||||||
|
Internal method for settings the methods up
|
||||||
|
|
||||||
|
Arguments:
|
||||||
|
methodNames - A list of the method names available.
|
||||||
|
|
||||||
|
*/
|
||||||
|
_setMethods: function(methodNames) {
|
||||||
var components = new Hash();
|
var components = new Hash();
|
||||||
|
|
||||||
methodNames.forEach(function(method) {
|
methodNames.forEach(function(method) {
|
||||||
|
@ -69,7 +84,6 @@ JSON.RPC = new Class({
|
||||||
components.each(function(methods, name) {
|
components.each(function(methods, name) {
|
||||||
this[name] = methods;
|
this[name] = methods;
|
||||||
}, this);
|
}, this);
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue