Ohm-Management - Projektarbeit B-ME
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

presence_filter.js 1.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. // Copyright 2014 Mark Cavage, Inc. All rights reserved.
  2. // Copyright 2014 Patrick Mooney. All rights reserved.
  3. var util = require('util');
  4. var assert = require('assert-plus');
  5. var helpers = require('./helpers');
  6. ///--- API
  7. function PresenceFilter(options) {
  8. if (typeof (options) === 'object') {
  9. assert.string(options.attribute, 'options.attribute');
  10. this.attribute = options.attribute;
  11. }
  12. var self = this;
  13. this.__defineGetter__('type', function () { return 'present'; });
  14. this.__defineGetter__('json', function () {
  15. return {
  16. type: 'PresenceMatch',
  17. attribute: self.attribute
  18. };
  19. });
  20. }
  21. util.inherits(PresenceFilter, helpers.Filter);
  22. PresenceFilter.prototype.toString = function () {
  23. return '(' + helpers.escape(this.attribute) + '=*)';
  24. };
  25. PresenceFilter.prototype.matches = function (target, strictAttrCase) {
  26. assert.object(target, 'target');
  27. var value = helpers.getAttrValue(target, this.attribute, strictAttrCase);
  28. return (value !== undefined && value !== null);
  29. };
  30. ///--- Exports
  31. module.exports = PresenceFilter;