Permalink
Browse files

- call the `beforeCollapse` hook

- added "unconditional pin object as" method to scope
  • Loading branch information...
1 parent f0a7acc commit 20462cebd469ca38bb9d2fcdc8ad18a658536efb Nickolay Platonov committed Dec 3, 2010
Showing with 19 additions and 2 deletions.
  1. +13 −1 lib/KiokuJS/Scope.js
  2. +6 −1 lib/KiokuJS/TypeMap/Joose.js
View
@@ -132,7 +132,19 @@ Class('KiokuJS.Scope', {
return this.pinNode(node)
},
-
+
+ // pin object with uncoditional ID
+ pinObjectAs : function (object, ID) {
+ if (this.objectPinned(object)) return this.objectToId(object)
+
+ var node = this.backend.createNodeFromObject(object)
+
+ node.ID = ID
+
+ return this.pinNode(node)
+ },
+
+
unpinObject : function (object) {
if (!this.objectPinned(object)) return
@@ -3,6 +3,7 @@ Class('KiokuJS.TypeMap.Joose', {
isa : 'KiokuJS.TypeMap',
use : [
+ 'KiokuJS.Aspect.BeforeCollapse',
'KiokuJS.Aspect.AfterCollapse',
'KiokuJS.Feature.Attribute.Skip',
'KiokuJS.Feature.Class.Immutable'
@@ -49,7 +50,8 @@ Class('KiokuJS.TypeMap.Joose', {
var instance = node.object
var meta = instance.meta
var isManagedClass = meta instanceof Joose.Managed.Class
- var data = {}
+
+ if (isManagedClass && meta.does(KiokuJS.Aspect.BeforeCollapse)) instance.beforeCollapse(node, collapser)
// if node already has `data`, then either it is being collapsed for the 2nd time or were loaded from the backend
// in both cases, if node represents an instance of immutable class, it becomes also immutable
@@ -60,6 +62,9 @@ Class('KiokuJS.TypeMap.Joose', {
return node.data
}
+
+ var data = {}
+
this.eachAttribute(instance, function (attribute, name, attributeLevel) {
if (attribute.hasValue(instance))

0 comments on commit 20462ce

Please sign in to comment.