Permalink
Browse files

[lib] cleanup

  • Loading branch information...
1 parent c4825a0 commit 494b7b96aed77de30d8b22bbbe55f6348666967d Paolo Fragomeni committed Dec 24, 2011
Showing with 10 additions and 28 deletions.
  1. +10 −28 lib/plates.js
View
@@ -188,45 +188,26 @@
if (!(this instanceof Mapper)) { return new Mapper(val); }
this.mappings = [];
};
-
- //
- // almost, but not quite...
- //
+
function last() {
if (this.mappings.length < 1) {
- return this.mappings.push({});
- }
- else {
- return this.mappings[this.mappings.length-1];
+ this.mappings.push({});
}
+ return this.mappings[this.mappings.length-1];
}
Mapper.prototype = {
use: function(val) {
last.call(this).dataKey = val;
- return this;
- },
- is: function(val) {
- last.call(this).value = val;
return this;
},
where: function(val) {
-
- if (typeof val === 'string') {
-
- this.mappings.push({
- "attribute": val,
- "replace": null
- });
- }
- else {
- //
- // TODO: Accept an object literal of attribute `ids`
- // to data `keys`. Lets iterate each one and build
- // up the mappings hash. By default, matches will be
- // made on a tag's IDs.
- //
- }
+ var map = last.call(this);
+ map.attribute = val;
+ return this;
+ },
+ is: function(val) {
+ last.call(this).value = val;
return this;
},
as: function(val) {
@@ -242,6 +223,7 @@
},
Map: Mapper
});
+
}();
if (typeof module !== 'undefined') {

0 comments on commit 494b7b9

Please sign in to comment.