<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>CHANGES</filename>
    </added>
    <added>
      <filename>examples/mop-examples.html</filename>
    </added>
    <added>
      <filename>examples/mop-examples.js</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -4,27 +4,13 @@ MOP = {
     Object: function(object) {
         var definers = {
             accessor: function(propertyName) {
-                var capitalized = name.slice(0, 1).toUpperCase() + name.slice(1);
-                object['get' + capitalized] = function() { return this[name] };
-                object['set' + capitalized] = function(value) { this[name] = value; };
+                var capitalized = propertyName.slice(0, 1).toUpperCase() + propertyName.slice(1);
+                object['get' + capitalized] = function() { return this[propertyName] };
+                object['set' + capitalized] = function(value) { this[propertyName] = value; };
             },
             getter: function(propertyName) {
-                var capitalized = name.slice(0, 1).toUpperCase() + name.slice(1);
-                object['get' + capitalized] = function() { return this[name] }
-            },
-            /** For each name in `methods`, defines a method on
-            `object` with this name, that delegates to the method of
-            the `propertyName` property of `object` with the same
-            name. */
-            delegate: function(propertyName, methods) {
-                for (var i = 0; i &lt; methods.length; i++)
-                    addMethod(methods[i]);
-                function addMethod(methodName) {
-                    object[methodName] = function() {
-                        var delegate = this[propertyName];
-                        return delegate[methodName].apply(delegate, arguments);
-                    }
-                }
+                var capitalized = propertyName.slice(0, 1).toUpperCase() + propertyName.slice(1);
+                object['get' + capitalized] = function() { return this[propertyName] }
             }
         };
         function method(methodName) {
@@ -73,22 +59,25 @@ MOP = {
             }
             function restore() { object[methodName] = fn }
         }
-        var modifiers = {
-            time: function(methodName) {
-                var fn = object[methodName];
-                object[methodName] = function() {
-                    var t0 = new Date,
-                        result = fn.apply(this, arguments),
-                        t1 = new Date;
-                    console.info(methodName, t1 - t0);
-                    return result;
-                }
-            }
-        };
-        return { define: definers, method: method, methods: modifiers };
+        return { define: definers, method: method,
+                 /** For each name in `methods`, defines a method on
+                    `object` with this name, that delegates to the method of
+                     the `propertyName` property of `object` with the same
+                     name. */
+                 delegate: function(propertyName, methods) {
+                     for (var i = 0; i &lt; methods.length; i++)
+                         addMethod(methods[i]);
+                     function addMethod(methodName) {
+                         object[methodName] = function() {
+                             var delegate = this[propertyName];
+                             return delegate[methodName].apply(delegate, arguments);
+                         }
+                     }
+                 }
+               }
     },
     
-    Class: function(klass) { return Object(klass.prototype) },
+    Class: function(klass) { return this.Object(klass.prototype) },
     
     
     /** When a new MethodReplacer is constructed, it replaces</diff>
      <filename>lib/mop-utilities.js</filename>
    </modified>
    <modified>
      <diff>@@ -2,17 +2,17 @@ describe('MOP.delegate', {
     'should delegate to the named field': function() {
         var captures = [];
         var delegatee = {f: function(x) {captures.push(x); return 2}};
-        var delegator = {d: delegatee};
-        MOP.delegate(delegator, 'd', ['f']);
-        value_of(delegator.f(1)).should_be(2);
+        var object = {d: delegatee};
+        MOP.Object(object).delegate('d', ['f']);
+        value_of(object.f(1)).should_be(2);
         value_of(captures.join(',')).should_be('1');
     },
     'should leave other methods alone': function() {
         var captures = [];
         var delegatee = {f: function(x) {captures.push(x); return 2}};
-        var delegator = {d: delegatee, g: function(x) {return 3}};
-        MOP.delegate(delegator, 'd', ['f']);
-        value_of(delegator.g(1)).should_be(3);
+        var object = {d: delegatee, g: function(x) {return 3}};
+        MOP.Object(object).delegate('d', ['f']);
+        value_of(object.g(1)).should_be(3);
         value_of(captures.join(',')).should_be('');
     },
     'should work on classes': function() {
@@ -21,13 +21,48 @@ describe('MOP.delegate', {
         function Delegator(delegatee) {
             this.d = delegatee;
         }
-        MOP.delegate(Delegator.prototype, 'd', ['f']);
-        var delegator = new Delegator(delegatee);
-        value_of(delegator.f(1)).should_be(2);
+        MOP.Class(Delegator).delegate('d', ['f']);
+        var object = new Delegator(delegatee);
+        value_of(object.f(1)).should_be(2);
         value_of(captures.join(',')).should_be('1');
     }
 });
 
+describe('MOP.define', {
+    'should define accessors': function() {
+        var object = {};
+        MOP.Object(object).define.accessor('name');
+        object.setName(1);
+        value_of(object.name).should_be(1);
+        value_of(object.getName()).should_be(1);
+    },
+    'should define getters': function() {
+        var object = {name:1};
+        MOP.Object(object).define.getter('name');
+        value_of(object.setName).should_be(undefined);
+        value_of(object.getName()).should_be(1);
+    },
+    'should apply to classes': function() {
+        function Klass() {};
+        MOP.Class(Klass).define.accessor('name');
+        var object = new Klass;
+        object.setName(1);
+        value_of(object.name).should_be(1);
+        value_of(object.getName()).should_be(1);
+    },
+});
+
+describe('MOP.method', {
+    'should define guardBy': function() {
+        var object = {f: function() { return 1 }};
+        var guarded = true;
+        MOP.Object(object).method('f').guardBy(function() { return !guarded });
+        value_of(object.f()).should_be(false);
+        guarded = false;
+        value_of(object.f()).should_be(1);
+    }
+});
+
 describe('MOP.MethodReplacer', {
     'should replace specified methods': function() {
         var object = {f: function(x) {return 1}};</diff>
      <filename>specs/mop-specs.js</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>7d112623709e10cf16c35650c7d51d32404cf3b7</id>
    </parent>
  </parents>
  <author>
    <name>Oliver Steele</name>
    <email>steele@osteele.com</email>
  </author>
  <url>http://github.com/osteele/mop-js/commit/506acb13b61719cda32c836183636d91175f9b5f</url>
  <id>506acb13b61719cda32c836183636d91175f9b5f</id>
  <committed-date>2008-04-18T21:07:36-07:00</committed-date>
  <authored-date>2008-04-18T21:07:36-07:00</authored-date>
  <message>added MOP.{Class,Object}.*

Moved MOP.delegate -&gt; MOP.{Class,Object}.delegate
Added MOP.{Class,Object}.define.{accessor,getter}
Added MOP.{Class,Object}.method.{guardBy,guardUntil,trace,time}</message>
  <tree>9472dfdb5773f5c21b134d3672fe0272e01cb086</tree>
  <committer>
    <name>Oliver Steele</name>
    <email>steele@osteele.com</email>
  </committer>
</commit>
