Skip to content

Commit

Permalink
- passing default superclass to prepareProperties (to allow potential…
Browse files Browse the repository at this point in the history
… delayed creation)
  • Loading branch information
canonic-epicure committed Oct 27, 2009
1 parent f9e8605 commit fe85e77
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 18 deletions.
12 changes: 4 additions & 8 deletions lib/Joose/Namespace/Manager.js
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ Joose.Namespace.Manager = new Joose.Managed.Class('Joose.Namespace.Manager', {
// },


prepareProperties : function (name, props) {
prepareProperties : function (name, props, defaultMeta) {
if (typeof name != 'string') {
props = name
name = null
Expand All @@ -170,7 +170,7 @@ Joose.Namespace.Manager = new Joose.Managed.Class('Joose.Namespace.Manager', {
var me = this

return function (name, props) {
var args = me.prepareProperties(name, props)
var args = me.prepareProperties(name, props, metaClass)

args.meta = args.meta || metaClass

Expand Down Expand Up @@ -201,24 +201,20 @@ Joose.Namespace.Manager = new Joose.Managed.Class('Joose.Namespace.Manager', {


Class : function (name, props) {
var args = this.prepareProperties(name, props)
var args = this.prepareProperties(name, props, Joose.Meta.Class)

if (!args.meta)
if (props && typeof props.isa == 'function')
args.meta = props.isa.meta.constructor
else
args.meta = Joose.Meta.Class

//to allow delayed meta declaration in nested classes
//if not a class
if (!args.meta.meta) args.meta = args.meta()

return this.create(args.name, args.meta, args.props)
},


Module : function (name, props) {
var args = this.prepareProperties(name, props)
var args = this.prepareProperties(name, props, Joose.Namespace.Keeper)

if (typeof args.props == 'function') args.props = { body : args.props }

Expand Down
12 changes: 4 additions & 8 deletions lib/Task/Joose/Core.js
Original file line number Diff line number Diff line change
Expand Up @@ -2984,7 +2984,7 @@ Joose.Namespace.Manager = new Joose.Managed.Class('Joose.Namespace.Manager', {
// },


prepareProperties : function (name, props) {
prepareProperties : function (name, props, defaultMeta) {
if (typeof name != 'string') {
props = name
name = null
Expand All @@ -3009,7 +3009,7 @@ Joose.Namespace.Manager = new Joose.Managed.Class('Joose.Namespace.Manager', {
var me = this

return function (name, props) {
var args = me.prepareProperties(name, props)
var args = me.prepareProperties(name, props, metaClass)

args.meta = args.meta || metaClass

Expand Down Expand Up @@ -3040,24 +3040,20 @@ Joose.Namespace.Manager = new Joose.Managed.Class('Joose.Namespace.Manager', {


Class : function (name, props) {
var args = this.prepareProperties(name, props)
var args = this.prepareProperties(name, props, Joose.Meta.Class)

if (!args.meta)
if (props && typeof props.isa == 'function')
args.meta = props.isa.meta.constructor
else
args.meta = Joose.Meta.Class

//to allow delayed meta declaration in nested classes
//if not a class
if (!args.meta.meta) args.meta = args.meta()

return this.create(args.name, args.meta, args.props)
},


Module : function (name, props) {
var args = this.prepareProperties(name, props)
var args = this.prepareProperties(name, props, Joose.Namespace.Keeper)

if (typeof args.props == 'function') args.props = { body : args.props }

Expand Down
4 changes: 2 additions & 2 deletions t/040_my_symbiont.t.js
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ StartTest(function (t) {


//==================================================================================================================================================================================
t.diag("'my' with custom (and delayed) meta")
t.diag("'my' with custom meta")

Class('CustomMeta', {

Expand All @@ -176,7 +176,7 @@ StartTest(function (t) {
Class('TestClass3', {

my : {
meta : function () { return CustomMeta },
meta : CustomMeta,

has : {
att3 : 'value3'
Expand Down

0 comments on commit fe85e77

Please sign in to comment.