Skip to content

Commit

Permalink
- aliasing Class/Module/Role to Joose.*
Browse files Browse the repository at this point in the history
  • Loading branch information
canonic-epicure committed Apr 4, 2010
1 parent ff800a8 commit 85706f8
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 9 deletions.
14 changes: 14 additions & 0 deletions Changes
@@ -1,3 +1,17 @@
3.007

[ENHANCEMENTS]

- Class/Role/Module in the global scope aliased as Joose.Class/Joose.Role/Joose.Module
- Joose no longer overwrites the Class/Role/Module symbols in global scope (should allow Prototype support)


[BUG FIXES]

- fixed bug, when traits weren't applied to the class with already detached meta
(when the meta already had traits)


3.006 Mon, Feb 22, 2010

[ENHANCEMENTS]
Expand Down
11 changes: 7 additions & 4 deletions lib/Joose/Namespace/Manager.js
Expand Up @@ -182,11 +182,14 @@ Joose.Namespace.Manager = new Joose.Managed.Class('Joose.Namespace.Manager', {
register : function (helperName, metaClass, func) {
var me = this

if (this.meta.hasMethod(helperName))
this.globalNs.addProperty(helperName, function () {
if (this.meta.hasMethod(helperName)) {
var helper = function () {
return me[helperName].apply(me, arguments)
})
else {
}

if (!Joose.top[helperName]) Joose.top[helperName] = helper
if (!Joose[helperName]) Joose[helperName] = helper
} else {
var methods = {}

methods[helperName] = func || this.getDefaultHelperFor(metaClass)
Expand Down
11 changes: 7 additions & 4 deletions lib/Task/Joose/Core.js
Expand Up @@ -3146,11 +3146,14 @@ Joose.Namespace.Manager = new Joose.Managed.Class('Joose.Namespace.Manager', {
register : function (helperName, metaClass, func) {
var me = this

if (this.meta.hasMethod(helperName))
this.globalNs.addProperty(helperName, function () {
if (this.meta.hasMethod(helperName)) {
var helper = function () {
return me[helperName].apply(me, arguments)
})
else {
}

if (!Joose.top[helperName]) Joose.top[helperName] = helper
if (!Joose[helperName]) Joose[helperName] = helper
} else {
var methods = {}

methods[helperName] = func || this.getDefaultHelperFor(metaClass)
Expand Down
24 changes: 23 additions & 1 deletion t/050_helpers.t.js
@@ -1,6 +1,6 @@
StartTest(function (t) {

t.plan(66)
t.plan(68)

//==================================================================================================================================================================================
t.diag("Modules")
Expand Down Expand Up @@ -426,6 +426,28 @@ StartTest(function (t) {
t.ok(TestProto, "Class with meta Joose.Proto.Class was successfully created via 'Class' helper")


//==================================================================================================================================================================================
t.diag("Class helpers and global scope")

var customSymbol = CustomSymbol = {}

Class('Test.Meta', {
isa : Joose.Meta.Class
})

Joose.Namespace.Manager.my.register('CustomSymbol', Test.Meta)


t.ok(customSymbol == CustomSymbol, "Global symbol wasn't overriden")

Joose.CustomSymbol('TestClass2', {
methods : {
process : function () { return 'res' }
}
})

t.ok(TestClass2.meta instanceof Test.Meta, "Helper for CustomSymbol metaclass was aliased to Joose.CustomSymbol")


//==================================================================================================================================================================================
t.diag("Modifying helper - should be the last test(!), as it modifies the 'Class'")
Expand Down

0 comments on commit 85706f8

Please sign in to comment.