Permalink
Browse files

getAll() and getAllAsArray() now return a copy instead of a reference

  • Loading branch information...
hay committed Mar 30, 2012
1 parent 2ea0687 commit 992c3776486e224ac9a41e2b002348551e9e5465
Showing with 9 additions and 4 deletions.
  1. +7 −1 index.html
  2. +2 −3 stapes.js
View
@@ -566,7 +566,10 @@ <h1>getAll</h1>
<h2>module.getAll();</h2>
- <p>Returns all attributes as an object.</p>
+ <p>Returns all the attributes of an module as an object. Handy for JSON
+ serializing and persistence layers.</p>
+
+ <p>Note that this method returns a copy/clone instead of a reference.</p>
</article>
<article id="m-getallasarray">
@@ -578,6 +581,8 @@ <h2>module.getAllAsArray();</h2>
Note that the original key of the attribute is always available as a
'id' key in the the value, provided your value is an object.</p>
+ <p>Note that this method returns a copy/clone instead of a reference.</p>
+
<p>Can be used as an easy way to get the number of attributes in a
module by using the <code>length</code> property of the
array</p>
@@ -708,6 +713,7 @@ <h3 id="m-history">History</h3>
<li><small>Feature</small> Added the <code><a href="m-mutate">mutate</a></code> change event.</li>
<li><small>Feature</small> <code><a href="m-update">update</a></code> now accepts a single function as an argument too.</li>
<li><small>Bugfix</small> Setting an attribute with the same value as the old value doesn't trigger a change event anymore.</li>
+ <li><code><a href="#m-getall">getAll()</a></code> and <code><a href="#m-getallasarray">getAllAsArray()</a></code> now return a clone of the attributes instead of a reference.</li>
<li>Removing the undocumented <code>changemany</code> and <code>createmany</code> events.</li>
</ul>
<li>0.2.1</li>
View
@@ -299,7 +299,7 @@
},
getAll : function() {
- return Stapes._attributes[this._guid];
+ return util.clone( Stapes._attributes[this._guid] );
},
getAllAsArray : function() {
@@ -313,8 +313,7 @@
arr.push(value);
});
- return arr;
-
+ return util.clone( arr );
},
has : function(key) {

0 comments on commit 992c377

Please sign in to comment.