How to use the clay.set_primary_storage function in clay

To help you get started, we’ve selected a few clay 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 Yipit / clay.js / test / unit / storage-mechanism.js View on Github external
'it is possible to set the default storage mechanism': function(){
        function FakeMechanismTwo (){models.storage.Mechanism.call(this)};
        util.inherits(FakeMechanismTwo, models.storage.Mechanism);

        var fake2 = new FakeMechanismTwo();

        models.set_primary_storage(fake2)

        var Build = models.declare('Build', function (it, kind){
            it.has.field("name", kind.string);
        });

        assert.deepEqual(fake2, Build._meta.storage);
    },
    'it defaults to the redis storage mechanism': function(){
github Yipit / clay.js / test / unit / models.js View on Github external
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE. */

var vows = require('vows')
, should = require('should')
, crypto = require('crypto')
, _ = require('underscore')._;

var models = require('clay');
var mock = new models.storage.Mechanism();

models.set_primary_storage(mock);

vows.describe('A Model').addBatch({
    'after declared': {
        topic: function () {
            return models.declare("Person", function(it, kind){
                it.has.field("username", kind.alphanumeric);
                it.has.field("email_address", kind.email);
                it.has.field("birthdate", kind.datetime);
                it.has.field("created_at", kind.auto);
                it.has.field("zipcode", kind.numeric);
                it.has.field("password", kind.string);

                it.validates.uniquenessOf("username");

                it.validates.presenceOf("username");
                it.validates.presenceOf("email_address");
github Yipit / clay.js / test / unit / issues.js View on Github external
OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
OTHER DEALINGS IN THE SOFTWARE. */

var vows = require('vows')
, should = require('should')
, crypto = require('crypto')
, _ = require('underscore')._;

var models = require('clay');
var mock = new models.storage.Mechanism();

models.set_primary_storage(mock);

var Foo = models.declare("Foo", function(it, kind){
    it.has.method('work', function(msg){
        return "foooooooooooooooooo"
    });
});

var Bar = models.declare("Bar", function(it, kind){
    it.has.method('work', function(msg){
        return "baaaaarrrrrrrrrrrrr"
    });
});

vows.describe('Model issues').addBatch({
    'can be declared sequentially': {
        topic: {