Skip to content

Instantly share code, notes, and snippets.

@canonic-epicure
Created June 30, 2010 06:41
Show Gist options
  • Save canonic-epicure/458325 to your computer and use it in GitHub Desktop.
Save canonic-epicure/458325 to your computer and use it in GitHub Desktop.
require.paths.unshift('/home/nickolay/Playground/nodejs');
require('Task/Joose/NodeJS');
var sys = require('sys');
Joose.Module('SuperStuff', {
require : [ 'faye'],
use : [ 'Task/JooseX/Class/SimpleConstructor/Core', 'Task/JooseX/Role/Parameterized/Core', 'JooseX/Class/Singleton' ],
body : function (m) {
Joose.Role('MyFirstParamd', {
meta : JooseX.Role.Parameterized,
parameter : {
methodsMatching : null
},
introspect : true,
role : function (self, consumer) {
var role = {
override : {}
}
consumer.meta.getMethods().each(function (method, name) {
if (self.methodsMatching.test(name)) {
role.override[ name ] = function () {
sys.puts('this is incredible')
// this.SUPERARG(arguments)
sys.puts('I set it with the dollar sign thing')
}
}
})
return role
}
})
Joose.Class('WillParam', {
trait : JooseX.Class.SimpleConstructor,
does : SuperStuff['MyFirstParamd']({ methodsMatching : /^bob$/ }),
// does : SuperStuff['MyFirstParamd']({ methodsMatching : /^.+\$(.+)\$(WOWZERS)$/ }),
has : {
things : { is : 'rw', init : 'someText' }
},
methods : {
bob : function (val) {
this.setThings(val);
}
}
})
SuperStuff['myVar'] = SuperStuff['WillParam']();
sys.puts(SuperStuff['myVar'].getThings());
SuperStuff['myVar'].bob()
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment