Skip to content

Commit

Permalink
Changed getCollection method and updated version
Browse files Browse the repository at this point in the history
  • Loading branch information
Paolo Scanferla committed May 8, 2014
1 parent afa2229 commit 13ddec1
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 8 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ var ceres = new Asteroid("localhost:3000");

// Use real-time collections
ceres.subscribe("tasks");
var tasks = ceres.getCollection("tasks");
var tasks = ceres.createCollection("tasks");
tasks.insert({
description: "Do the laundry"
});
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "asteroid",
"version": "0.2.1",
"version": "0.2.2",
"homepage": "https://github.com/mondora/asteroid",
"authors": [
"Paolo Scanferla <[email protected]>"
Expand Down
10 changes: 8 additions & 2 deletions dist/asteroid.js
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ Asteroid.prototype.call = function (method /* , param1, param2, ... */) {
};

Asteroid.prototype.apply = function (method, params) {
// Assert name must be a string
// Assert method must be a string
must.beString(method);
// Create the result and updated promises
var resultDeferred = Q.defer();
Expand Down Expand Up @@ -326,7 +326,13 @@ Asteroid.prototype.apply = function (method, params) {
// Syntactic sugar //
/////////////////////

Asteroid.prototype.getCollection = function (name) {
Asteroid.prototype.createCollection = function (name) {
// Assert on arguments type
must.beString(name);
// Only create the collection if it doesn't exist
if (!this.collections[name]) {
this.collections[name] = new Asteroid._Collection(name, this);
}
return this.collections[name];
};

Expand Down
2 changes: 1 addition & 1 deletion dist/asteroid.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "asteroid",
"version": "0.2.1",
"version": "0.2.2",
"description": "Aletrnative Meteor client",
"main": "dist/asteroid.js",
"scripts": {
Expand Down
10 changes: 8 additions & 2 deletions src/asteroid.js
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ Asteroid.prototype.call = function (method /* , param1, param2, ... */) {
};

Asteroid.prototype.apply = function (method, params) {
// Assert name must be a string
// Assert method must be a string
must.beString(method);
// Create the result and updated promises
var resultDeferred = Q.defer();
Expand Down Expand Up @@ -218,6 +218,12 @@ Asteroid.prototype.apply = function (method, params) {
// Syntactic sugar //
/////////////////////

Asteroid.prototype.getCollection = function (name) {
Asteroid.prototype.createCollection = function (name) {
// Assert on arguments type
must.beString(name);
// Only create the collection if it doesn't exist
if (!this.collections[name]) {
this.collections[name] = new Asteroid._Collection(name, this);
}
return this.collections[name];
};

0 comments on commit 13ddec1

Please sign in to comment.