Skip to content

Commit

Permalink
Issue #139: remove util/Config (and then util/Map)
Browse files Browse the repository at this point in the history
- Removed util/Config and util/Map (because only util/Config depended on it)
  and unit tests
- Side effect: mvc/Model depended on Config, but only to get the apiRoot in
  Model#getApiURL. We now do that in project-specfic Service classes, so I
  removed that method.
- Side effect: mvc/Application depended on Config, which it passed to
  Application#beforeInit for subclasses to override. My line of thinking is
  that subclasses can load this themselves.
  • Loading branch information
zship committed Jul 31, 2014
1 parent 850a816 commit 08f1ab9
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 420 deletions.
9 changes: 3 additions & 6 deletions src/mvc/Application.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ define(function(require) {
EventDispatcher = require('lavaca/events/EventDispatcher'),
router = require('lavaca/mvc/Router'),
viewManager = require('lavaca/mvc/ViewManager'),
Connectivity = require('lavaca/net/Connectivity'),
Config = require('lavaca/util/Config');
Connectivity = require('lavaca/net/Connectivity');

function _stopEvent(e) {
e.preventDefault();
Expand Down Expand Up @@ -53,7 +52,7 @@ define(function(require) {
this._callback = callback.bind(this);
}
Device.init(function() {
this.beforeInit(Config)
this.beforeInit()
.then(this.init.bind(this));
}.bind(this));
}, {
Expand Down Expand Up @@ -223,11 +222,9 @@ define(function(require) {
* Handles asynchronous requests that need to happen before Application.init() is called in the constructor
* @method {String} beforeInit
*
* @param {Lavaca.util.Config} Config cache that's been initialized
*
* @return {Promise} A promise
*/
beforeInit: function(Config) {
beforeInit: function() {
return Promise.resolve(null);
}
});
Expand Down
20 changes: 1 addition & 19 deletions src/mvc/Model.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ define(function(require) {
clone = require('mout/lang/deepClone'),
contains = require('mout/array/contains'),
removeAll = require('mout/array/removeAll'),
merge = require('mout/object/merge'),
Config = require('lavaca/util/Config');
merge = require('mout/object/merge');


var UNDEFINED;
Expand Down Expand Up @@ -382,23 +381,6 @@ define(function(require) {
return _isValid(messages);
}
},
/**
* Converts a relative path to an absolute api url based on environment config 'apiRoot'
* @method getApiURL
*
* @param {String} relPath A relative path
* @return {String} A formated api url or an apparently bad url '/please_set_model_url' if relPath argument is faslsy
*/
getApiURL: function(relPath) {
var badURL = '/please_set_model_url',
apiRoot = Config.get('apiRoot'),
apiURL;
if (!relPath) {
return badURL;
}
apiURL = (apiRoot || '') + relPath;
return apiURL;
},
/**
* Converts this model to a key-value hash
* @method toObject
Expand Down
88 changes: 0 additions & 88 deletions src/util/Config.js

This file was deleted.

209 changes: 0 additions & 209 deletions src/util/Map.js

This file was deleted.

Loading

0 comments on commit 08f1ab9

Please sign in to comment.