why is Model.init implemented like this?

Showing 1-7 of 7 messages
why is Model.init implemented like this? andreas schmid 5/17/12 9:59 AM

as difined here:

Module.init is implemented like:

Module.init = Controller.init = Model.init = (a1, a2, a3, a4, a5) ->
 
new this(a1, a2, a3, a4, a5)

why is it like this? why define 5 attributes and not use attrs... so attributes are not fixed to 5....

new this(attrs...)
Re: [Spine] why is Model.init implemented like this? Alex MacCaw 5/17/12 1:50 PM
You can't do that with JavaScript unfortunately. --
Alex MacCaw

+12147175129
@maccman

http://alexmaccaw.co.uk
Re: [Spine] why is Model.init implemented like this? andreas schmid 5/17/12 7:17 PM
this is taken from spine.coffee so yes you can:


which translates into
var __slice = [].slice;

Module.init = Controller.init = Model.init = function() {
 
var args;
  args
= 1 <= arguments.length ? __slice.call(arguments, 0) : [];
 
return (function(func
...
unk...@googlegroups.com 5/17/12 11:39 PM <This message has been deleted.>
Re: [Spine] why is Model.init implemented like this? Alex MacCaw 5/18/12 1:16 AM
Yes, you're right - I take that back, sorry! 

However, that's an awful lot of code :) - I'm actually taking out .init() in the next version of Spine anyhow. 

 
return (function(func, args, ctor) {
    ctor
.prototype = func.prototype;
   
var child = new ctor, result =
...
Re: [Spine] why is Model.init implemented like this? andreas schmid 5/18/12 6:02 AM
trust me i trust you! :)

and i admit i don't know too much about js. this question was more an didactical one.
Re: [Spine] why is Model.init implemented like this? Alex MacCaw 5/18/12 7:31 AM
Yes, a but too much hubris on my part there :)



   
var child = new ctor, result = func.
...