viewmodel
Advanced tools
Comparing version 0.2.5 to 0.3.0
@@ -1,4 +0,1 @@ | ||
// lib/queue.js v0.1.0 | ||
// (c) 2012 Adriano Raiano (adrai); under MIT License | ||
var fs = require('fs') | ||
@@ -82,50 +79,65 @@ , _ = require('underscore'); | ||
module.exports = { | ||
var WriteRepository = function() {}; | ||
write: { | ||
WriteRepository.prototype = { | ||
getNewViewModel: function(id) { | ||
return this.fromObject({ id: id, actionOnCommit: 'create', _revision: 1 }); | ||
}, | ||
getNewViewModel: function(id) { | ||
return this.fromObject({ id: id, actionOnCommit: 'create', _revision: 1 }); | ||
}, | ||
fromViewModel: fromViewModel, | ||
fromObject: function(obj) { | ||
var self = this; | ||
var vm = _.clone(obj); | ||
vm.actionOnCommit = vm.actionOnCommit || 'update'; | ||
vm.destroy = destroy; | ||
vm.commit = function(callback) { | ||
self.commit(this, callback); | ||
}; | ||
vm.toJSON = function() { return fromViewModel(this); }; | ||
vm.set = set; | ||
vm.get = get; | ||
return vm; | ||
}, | ||
init: function(options, callback) { | ||
initialize(this, options, callback); | ||
} | ||
fromViewModel: fromViewModel, | ||
fromObject: function(obj) { | ||
var self = this; | ||
var vm = _.clone(obj); | ||
vm.actionOnCommit = vm.actionOnCommit || 'update'; | ||
vm.destroy = destroy; | ||
vm.commit = function(callback) { | ||
self.commit(this, callback); | ||
}; | ||
vm.toJSON = function() { return fromViewModel(this); }; | ||
vm.set = set; | ||
vm.get = get; | ||
return vm; | ||
}, | ||
read: { | ||
init: function(options, callback) { | ||
initialize(this, options, callback); | ||
} | ||
getNewViewModel: function(id) { | ||
return null; | ||
}, | ||
}; | ||
fromViewModel: fromViewModel, | ||
fromObject: function(obj) { | ||
return obj; | ||
}, | ||
var ReadRepository = function() {}; | ||
init: function(options, callback) { | ||
initialize(this, options, callback); | ||
} | ||
ReadRepository.prototype = { | ||
getNewViewModel: function(id) { | ||
return null; | ||
}, | ||
fromViewModel: fromViewModel, | ||
fromObject: function(obj) { | ||
return obj; | ||
}, | ||
init: function(options, callback) { | ||
initialize(this, options, callback); | ||
} | ||
}; | ||
var repository = { | ||
write: new WriteRepository(), | ||
read: new ReadRepository() | ||
}; | ||
repository.write.create = function() { | ||
return new WriteRepository(); | ||
}; | ||
repository.read.create = function() { | ||
return new ReadRepository(); | ||
}; | ||
module.exports = repository; |
{ | ||
"author": "adrai", | ||
"name": "viewmodel", | ||
"version": "0.2.5", | ||
"version": "0.3.0", | ||
"private": false, | ||
@@ -6,0 +6,0 @@ "main": "index.js", |
@@ -6,2 +6,17 @@ var expect = require('expect.js') | ||
describe('calling create', function() { | ||
describe('on read (or write)', function() { | ||
it('it should return the same type of object as the singleton instance', function() { | ||
var newReadRepo = repository.read.create(); | ||
expect(newReadRepo.init).to.eql(repository.read.init); | ||
}); | ||
}); | ||
}); | ||
describe('calling init', function() { | ||
@@ -8,0 +23,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
68541
1498
164