On Wed, Nov 2, 2011 at 13:39, Mikeal Rogers <[email protected]> wrote:
>
> var generateModelClass = function(columns) {
>
>   var definition = {};
>
>   columns.forEach(function(col) {
>     definition['get' + col] = function() {
>       return this[col];
>     };
>     definition['set' + col] = function(value) {
>       return this[col] = value;
>     };
>   });
>
>   return class definition;
>
> };
>
>
I feel like this is too strange to my liking. With something more along
what Brendan was suggesting the same could be done like this:

var generateModelClass = function(columns) {
  var c = class {},
      p = returnClass.prototype;

  columns.forEach(function(col) {
    p['get' + col] = function() {
      return this[col];
    };
    p['set' + col] = function(value) {
      return this[col] = value;
    };
  });

  return c;
};


-- 
erik
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to