Open alexspeller opened 11 years ago
This is a bit of a horrible implementation but it's less duplication in use and minification safe:
Em.superAuto = (keys..., func) -> str = func.toString() regex = /function\s*\(\s*\)/ arrayRegex = /\@|\[\]/ unless str.match(regex) throw "It doesn't look like you passed a function with no arguments" argNames = for key in keys splitKey = key.split arrayRegex splitKey[0].camelize() str = str.replace(regex, "function(#{argNames.join(', ')})") eval("funcWithArgs = #{str}") Em.computed keys..., -> args = for key in keys @get key.split(arrayRegex)[0] funcWithArgs(args...)
jsbin
See the conversation at http://discuss.emberjs.com/t/ember-auto-nicer-properties-with-less-this-get-junk/2896/10
This is a bit of a horrible implementation but it's less duplication in use and minification safe:
jsbin