Just pass it before "initialization" object (the one that defines instance methods and constructor). You could pass as many mixins as you want this way:
var Vulnerable = { getShot: function() { this.health -= 20; }, } var Dangerous = { shoot: function(other) { other.getShot(); } } var Person = Class.create( Vulnerable, Dangerous, { initialize: function() { this.health = 100; this.dead = false; } }) var attacker = new Person; var victim = new Person; attacker.shoot(victim); victim.health; // => 80 attacker.shoot(victim); victim.health; // => 60 // etc. Best, kangax On Mar 26, 4:15 pm, [EMAIL PROTECTED] wrote: > Could someone show me a code snippet for mixing in mutiple mixins into > a class? Say I have the Vulnerable and Dangerous mixins and I want to > mix it into a Person class. My problem is I can do > var Person = Class.create(Vulnerable, { > initialize: function() { > this.health = 100; > this.dead = false; > }}); > > but how do I mixin Dangerous? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Spinoffs" group. To post to this group, send email to rubyonrails-spinoffs@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---