How to use the comb.define function in comb

To help you get started, we’ve selected a few comb examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github C2FO / hare / lib / index.js View on Github external
return function connect(url, opts) {
        if (!connectionPromise) {
            connectOpts = opts;
            connectionPromise = new Promise();
            connection = amqp.createConnection(url, opts);
            connection.once('ready', ready);
            connection.once('error', connectionError);
            // use on instead of once for `close` so we can handle multiple
            // subsequent disconnects.
            connection.on("close", checkConnected);
        }
        return connectionPromise;
    };
}());

var Hare = comb.define(_Options, {

    instance: {

        _url: null,

        constructor: function () {
            this._super(arguments);
            this._url = {};
        },

        url: function (url) {
            if (isHash(url)) {
                this._url = url;
            } else {
                this._url.url = url;
            }
github C2FO / patio / test / helpers / helper.js View on Github external
var comb = require("comb"),
    patio = require("../../lib"),
    Dataset = patio.Dataset,
    Database = patio.Database;

patio.quoteIdentifiers = false;

var MockDataset = comb.define(Dataset, {
    instance: {
        insert: function () {
            return this.db.execute(this.insertSql.apply(this, arguments));
        },

        update: function () {
            return this.db.execute(this.updateSql.apply(this, arguments));
        },

        fetchRows: function (sql, cb) {
            this.db.execute(sql);
            return comb.async.array({id: 1, x: 1});
        },

        _quotedIdentifier: function (c) {
            return '"' + c + '"';
github C2FO / hare / lib / queue.js View on Github external
"use strict";
var comb = require("comb"),
    merge = comb.merge,
    when = comb.when,
    Promise = comb.Promise,
    _Options = require("./_options"),
    _GetConnection = require("./_getConnection.js"),
    ERROR_FORMATTER = comb("%s's listener done with error\n");


function errorHandler(err) {
    console.error(err);
    throw err;
}

return comb.define([_Options, _GetConnection], {
    instance: {

        constructor: function Queue(name) {
            this._super(arguments);
            this.queueName = name || '';
            this.__queue = null;
            this.__queuePromise = null;
            this._subscribeOptions = {};
            this.__connection;
            this._defaultExchange = null;
            this.set("exchange", "amq.direct");
        },

        __getQueue: function __getQueue() {
            var queueName = this.queueName, self = this;
            if (!this.__queuePromise) {
github doug-martin / super-request / index.js View on Github external
methods.forEach(function (method) {
    var name = 'delete' === method ? 'del' : method;
    method = method.toUpperCase();
    promiseInstance[name] = function (url) {
        var test = this._test;
        return new Test(test.app, method, url).wait(this).jar(test._jar);
    };
});


var TestPromise = comb.define(comb.Promise, {
    instance: promiseInstance
});

Test = comb.define(null, {
    instance: {

        _wait: null,

        constructor: function (app, method, path) {
            this.method = method;
            var self = this._static;
            this.app = app;
            if (isString(app)) {
                this._baseUrl = app;
            } else {
                var addr = app.address();
                var portno = addr ? addr.port : self.PORT++;
                if (!addr) {
                    app.listen(portno);
                }
github C2FO / patio / lib / plugins / query.js View on Github external
var comb = require("comb"),
    asyncArray = comb.async.array,
    when = comb.when,
    isBoolean = comb.isBoolean,
    isArray = comb.isArray,
    isHash = comb.isHash,
    isUndefined = comb.isUndefined,
    isInstanceOf = comb.isInstanceOf,
    isEmpty = comb.isEmpty,
    Dataset = require("../dataset"),
    ModelError = require("../errors").ModelError,
    Promise = comb.Promise,
    PromiseList = comb.PromiseList;


var QueryPlugin = comb.define(null, {
    instance: {
        /**@lends patio.Model.prototype*/

        _getPrimaryKeyQuery: function () {
            var q = {}, pk = this.primaryKey;
            for (var i = 0, l = pk.length; i < l; i++) {
                var k = pk[i];
                q[k] = this[k];
            }
            return q;
        },

        _clearPrimaryKeys: function () {
            var pk = this.primaryKey;
            for (var i = 0, l = pk.length; i < l; i++) {
                this.__values[pk[i]] = null;
github C2FO / hare / lib / exchange.js View on Github external
"use strict";
var comb = require("comb"),
    Queue = require("./queue"),
    _Options = require("./_options"),
    _GetConnection = require("./_getConnection"),
    Promise = comb.Promise,
    when = comb.when,
    LOGGER = comb.logger("hare.exchange");

var ExchangeQueue = comb.define(Queue, {

    instance: {

        constructor: function (name, exchange) {
            this._super(arguments);
            this._exchange = exchange;
            this.exchange(exchange.exchangeName);
        },

        publish: function (routingKey, message, opts) {
            var argLength = arguments.length;
            if (argLength === 1) {
                message = routingKey;
                routingKey = this.queueName || this.get("routingKey") || '';
                opts = null;
            } else if (argLength === 2 && !comb.isString(routingKey) && comb.isHash(message)) {
github C2FO / patio / lib / plugins / columnMapper.js View on Github external
AliasedExpression = sql.AliasedExpression,
    Identifier = sql.Identifier,
    isConditionSpecifier = sql.Expression.isConditionSpecifier,
    ModelError = require("../errors.js").ModelError;


/**
 * @class This plugin exposes the ability to map columns on other tables to this Model.
 *
 * See {@link patio.plugins.ColumnMapper.mappedColumn} for more information.
 *
 * @name ColumnMapper
 * @memberof patio.plugins
 *
 */
comb.define(null, {

    "static": {

        /**@lends patio.plugins.ColumnMapper*/

        /**
         * Boolean flag indicating if mapped columns should be re-fetched on update.
         *
         * <b>NOTE</b> This can be overridden by passing {reload : false} to the {@link patio.Model#update} method.
         * @default true
         */
        fetchMappedColumnsOnUpdate: true,

        /**
         * Boolean flag indicating if mapped columns should be re-fetched on save.
         *
github C2FO / patio / lib / plugins / inheritance.js View on Github external
var comb = require("comb"),
    asyncArray = comb.async,
    Promise = comb.Promise,
    PromiseList = comb.PromiseList;

comb.define(null, {
    instance: {},
    "static": {

        configure: function (model) {

        }
    }
}).as(exports, "SingleTableInheritance");


/**
 * @class This plugin enables
 * <a href="http://www.martinfowler.com/eaaCatalog/classTableInheritance.html">
 *     class table inheritance
 * </a>.
 *
github C2FO / patio / lib / plugins / cache.js View on Github external
var LOGGER = comb.logging.Logger.getLogger("patio.plugins.CachePlugin");
/**
 * @class Adds in memory caching support for models.
 *
 * @example
 *
 * var MyModel = patio.addModel("testTable", {
 *     plugins : [patio.plugins.CachePlugin];
 * });
 *
 * //NOW IT WILL CACHE
 *
 * @name CachePlugin
 * @memberOf patio.plugins
 */
exports.CachePlugin = comb.define(null, {
    instance: {

        constructor: function () {
            this._super(arguments);
            this.post("load", this._postLoad);
            this._static.initHive();
        },

        reload: function () {
            var self = this;
            return this._super(arguments).chain(function (m) {
                hive.replace((self.tableName.toString() + self.primaryKeyValue.toString()), m);
                return m;
            });
        },
github doug-martin / ssrs / lib / server.js View on Github external
IterablePromise = require("./util/iterablePromise"),
    querystring = require("querystring"),
    URL = require("url"),
    Report = require("./report"),
    Csv = require("./csv"),
    Html4 = require("./html4"),
    Html3 = require("./html3"),
    Image = require("./image"),
    MHTML = require("./mhtml"),
    PDF = require("./pdf"),
    Word = require("./word"),
    Xml = require("./xml"),
    Excel = require("./excel"),
    request = require("request");

comb.define(null, {
    instance:{
        constructor:function (server, options) {
            this.server = server;
            options = options || {};
            this._opts = options;
            this._url = URL.parse(server, false);
            var self = this._static
            self.AUTH_PARAMS.forEach(function (i) {
                this[i] = function (cmd) {
                    return options[i] = cmd;
                };
            }, this);
        },

        auth:function (cmd, val) {
            var opts = this._opts;