Navigation Menu

Skip to content

Commit

Permalink
Move toTableNamePart to the class Domain itself and define new class …
Browse files Browse the repository at this point in the history
…method toDonamName
  • Loading branch information
piroor committed Aug 3, 2012
1 parent 37bade5 commit b178261
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions lib/database/domain.js
Expand Up @@ -106,7 +106,7 @@ Domain.prototype = {
},
getIdFromDatabase: function() {
if (this.context) {
var tableName = this.toTableNamePart(this.name);
var tableName = Domain.toTableNamePart(this.name);
var tables = this.context.tableListSync();
var tableIdMatcher = new RegExp('^' + DOMAIN_TABLE_PREFIX + '_' + tableName + '_([^_]+)$');
var id;
Expand Down Expand Up @@ -137,18 +137,15 @@ Domain.prototype = {
if (!this._tableName) {
assertValidDomainName(this.name);
this._tableName = DOMAIN_TABLE_PREFIX + '_' +
this.toTableNamePart(this.name) + '_' + this.id;
Domain.toTableNamePart(this.name) + '_' + this.id;
}
return this._tableName;
},
toTableNamePart: function(string) {
return string;
},

get referenceTableBaseName() {
if (!this._referenceTableBaseName)
this._referenceTableBaseName = REFERENCE_TABLE_PREFIX + '_' +
this.toTableNamePart(this.name) + '_' + this.id;
Domain.toTableNamePart(this.name) + '_' + this.id;
return this._referenceTableBaseName;
},

Expand Down Expand Up @@ -321,14 +318,21 @@ Domain.getNameAndIdFromPath = function(path) {
return { name: '', id: '' };
};

Domain.toTableNamePart = function(domainName) {
return domainName;
};
Domain.toDonamName = function(tableNamePart) {
return tableNamePart;
};

Domain.getAll = function(context) {
var tables = context.tableListSync();
var tableMatcher = new RegExp('^' + DOMAIN_TABLE_PREFIX + '_([^_]+)_([^_]+)$');
var domains = [];
tables.forEach(function(table) {
var match = table.name.match(tableMatcher);
if (match) {
var name = match[1]; // XXX this must be "unescape"d in the future.
var name = Domain.toDonamName(match[1]);
domains.push(new Domain(name, context));
}
});
Expand Down

0 comments on commit b178261

Please sign in to comment.