(function(app) {
  'use strict';

  var jCore = require('jcore');
  var helper = app.helper || require('../helper.js');

  var LockRelation = helper.inherits(function(props) {
    this.type = props.type;
    this.unit = props.unit;
    this.wire = props.wire;
  }, jCore.Relation);

  LockRelation.prototype.positionType = (function() {
    var map = { plug: 'source', socket: 'target' };
    return function() {
      return map[this.type];
    };
  })();

  LockRelation.prototype.equal = function(other) {
    return (!!other && Object.keys(this).every(function(key) {
      return helper.equal(this[key], other[key]);
    }.bind(this)));
  };

  LockRelation.prototype.update = function() {
    var wire = this.wire;
    var positionType = this.positionType();
    var position = this.unit[this.type + 'Position']();

    wire[positionType + 'X'](position.x);
    wire[positionType + 'Y'](position.y);
  };

  LockRelation.TYPE_PLUG = 'plug';
  LockRelation.TYPE_SOCKET = 'socket';

  if (typeof module !== 'undefined' && module.exports) {
    module.exports = LockRelation;
  } else {
    app.LockRelation = LockRelation;
  }
})(this.app || (this.app = {}));

@@ -305,24 +305,16 @@
 ype.
-positionType
+equal
  = 
-(
 func
@@ -314,32 +314,37 @@
  = function(
+other
 ) %7B%0A    
 var map = %7B 
@@ -335,67 +335,51 @@
     
-var map = %7B plug: 'source', socket: 'target' %7D;%0A    return 
+return (!!other && Object.keys(this).every(
 func
@@ -375,32 +375,35 @@
 .every(function(
+key
 ) %7B%0A      return
@@ -407,37 +407,68 @@
 urn 
-map%5Bthis.type%5D;%0A    %7D
+helper.equal(this%5Bkey%5D, other%5Bkey%5D);%0A    %7D.bind(this)))
 ;%0A  %7D
-)()
 ;%0A%0A 
@@ -483,37 +483,44 @@
 ation.prototype.
-equal
+unitPosition
  = function(othe
@@ -511,37 +511,32 @@
  = function(
-other
 ) %7B%0A    
 return (!!ot
@@ -527,134 +527,114 @@
     
-return (!!other && Object.keys(this).every(function(key) %7B%0A      return helper.equal(this%5Bkey%5D, other%5Bkey%5D);%0A    %7D.bind(this))
+var methodName = LockRelation.TYPE_POSITION_TABLE%5Bthis.type%5D.methodName;%0A    return this.unit%5BmethodName%5D(
 );%0A 
@@ -667,14 +667,20 @@
 ype.
-update
+wirePosition
  = f
@@ -679,32 +679,40 @@
 tion = function(
+position
 ) %7B%0A    var wire
@@ -752,45 +752,75 @@
 e = 
-this.positionT
+LockRelation.TYPE_POSITION_TABLE%5Bthis.type%5D.t
 ype
-()
 ;%0A    
-var 
+wire%5B
 position
  = t
@@ -819,49 +819,33 @@
 tion
- = this.unit%5Bthis.t
+T
 ype + '
-P
+X'%5D(p
 osition
-'%5D(
+.x
 );%0A
-%0A
     
@@ -857,33 +857,33 @@
 positionType + '
-X
+Y
 '%5D(position.x);%0A
@@ -882,62 +882,271 @@
 ion.
-x
+y
 );%0A  
-  wire%5BpositionType + 'Y'%5D(position.y);%0A  
+%7D;%0A%0A  LockRelation.prototype.update = function() %7B%0A    this.wirePosition(this.unitPosition());%0A  %7D;%0A%0A  LockRelation.TYPE_PLUG = 'plug';%0A  LockRelation.TYPE_SOCKET = 'socket';%0A%0A  LockRelation.TYPE_POSITION_TABLE = (function() %7B%0A    var table = %7B
 %7D;%0A
-%0A
   
+  table%5B
 Lock
@@ -1159,37 +1159,86 @@
 on.TYPE_PLUG
+%5D
  = 
-'plug';%0A  
+%7B methodName: 'plugPosition', type: 'source' %7D;%0A    table%5B
 LockRelation
@@ -1245,35 +1245,102 @@
 .TYPE_SOCKET
+%5D
  = 
-'socket'
+%7B methodName: 'socketPosition', type: 'target' %7D;%0A    return table;%0A  %7D)()
 ;%0A%0A  if (typ

Refactor method of updating lock-relation in terms of position