Fix control.json and exports

This commit is contained in:
Mark Cavage 2011-12-09 13:59:17 -08:00
parent ebde1df00c
commit ab94de8126
5 changed files with 22 additions and 11 deletions

View File

@ -38,11 +38,12 @@ function Control(options) {
var self = this;
this.__defineGetter__('json', function() {
return {
var obj = {
controlType: self.type,
criticality: self.criticality,
controlValue: self.value
};
return (typeof(self._json) === 'function' ? self._json(obj) : obj);
});
}
module.exports = Control;

View File

@ -39,11 +39,6 @@ function PersistentSearchControl(options) {
this.__defineGetter__('value', function() {
return self._value || {};
});
this.__defineGetter__('json', function() {
var json = Control.prototype.json.call(self);
json.controlValue = self.value;
return json;
});
}
util.inherits(PersistentSearchControl, Control);
module.exports = PersistentSearchControl;
@ -84,4 +79,11 @@ PersistentSearchControl.prototype._toBer = function(ber) {
};
PersistentSearchControl.prototype._json = function(obj) {
obj.controlValue = this.value;
return obj;
};
PersistentSearchControl.OID = '2.16.840.1.113730.3.4.3';

View File

@ -7,6 +7,7 @@ var Protocol = require('./protocol');
var Server = require('./server');
var assert = require('assert');
var controls = require('./controls');
var dn = require('./dn');
var errors = require('./errors');
var filters = require('./filters');
@ -15,6 +16,8 @@ var messages = require('./messages');
var schema = require('./schema');
var url = require('./url');
/// Hack a few things we need (i.e., "monkey patch" the prototype)
if (!String.prototype.startsWith) {
@ -73,6 +76,7 @@ module.exports = {
};
///--- Export all the childrenz
var k;
@ -87,6 +91,11 @@ for (k in messages) {
module.exports[k] = messages[k];
}
for (k in controls) {
if (controls.hasOwnProperty(k))
module.exports[k] = controls[k];
}
for (k in filters) {
if (filters.hasOwnProperty(k)) {
if (k !== 'parse' && k !== 'parseString')

View File

@ -16,9 +16,9 @@ var getControl;
///--- Tests
test('load library', function(t) {
Control = require('../../lib/controls/index').Control;
Control = require('../../lib/index').Control;
t.ok(Control);
getControl = require('../../lib/controls/index').getControl;
getControl = require('../../lib/index').getControl;
t.ok(getControl);
t.end();
});

View File

@ -14,10 +14,9 @@ var PersistentSearchControl;
///--- Tests
test('load library', function(t) {
PersistentSearchControl =
require('../../lib/controls').PersistentSearchControl;
PersistentSearchControl = require('../../lib').PersistentSearchControl;
t.ok(PersistentSearchControl);
getControl = require('../../lib/controls').getControl;
getControl = require('../../lib').getControl;
t.ok(getControl);
t.end();
});