My code:
Role('Loggable', {
use: ['JooseX.Role.Parameterized'],
meta: 'JooseX.Role.Parameterized',
parameter: {
logMethodsMatching: null
},
introspect: true,
role: function (self, consumer) {
if (null == self.logMethodsMatching)
{
return;
}
var role = {
override: {}
}
var methods = consumer.meta.getMethods();
methods.eachOwn(function (method, name) {
if (self.logMethodsMatching.test(name)) {
console.log('Call to method [' + name + '] - with
arguments [' + Array.prototype.slice(arguments) + ']')
var res = self.SUPERARG(arguments)
console.log('Returned result [' + res + ']')
return res;
}
});
return role;
}
});
...applied to this class:
Class('StartGameAction', {
// should apply to all instance methods
does: [com.nilbog.utility.role.Loggable({ logMethodsMatching: /^.+$/ })],
isa: m.Action,
has: {
gameDescription: { is: 'ro', required: true },
subActions: { is: 'ro', init: Joose.I.Array }
},
methods: {
execute: function () {
// removed
},
undo: function () {
// removed
},
startGame: function () {
// removed
}
}
});
Two problems:
1) The line 'var res = self.SUPERARG(arguments)' causes the error
'Invalid call to SUPER'
2) Without that line, I see the role is being applied to even the
generated accessors getGameDescription and getSubActions, which
SamuaiJack tells me should be impossible.
Any hints? S.Jack also recommended trying to implement Loggable as a
Meta Role that changes the default meta class of each instance method
instead. Has anyone gone this route?
--
John Mark Hawley
Design Technologist, Nilbog Group
http://www.nilbog.com
AIM: jmhnilbog
Twitter: johnmarkhawley
> --
> You received this message because you are subscribed to the Google Groups "Joose" group.
> To post to this group, send email to joos...@googlegroups.com.
> To unsubscribe from this group, send email to joose-js+u...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/joose-js?hl=en.
>
>