Created
November 11, 2011 20:18
-
-
Save k33g/1359112 to your computer and use it in GitHub Desktop.
kind of annotations with CoffeeScript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
__ = (from,name,member,annotation)-> | |
if not from.annotations then from.annotations = {} | |
if not from.annotations[name] then from.annotations[name] = {} | |
from.annotations[name][member] = annotation | |
class Human | |
__ @, "Model", "constructor", "localStorage" | |
__ @, "gui", "name", "name:input type = text" | |
__ @, "gui", "weight", "weight:input type = text" | |
__ @, "gui", "fields", {name : 'string', weight : 'integer'} | |
constructor: (name, weight) -> | |
@name = name | |
@weight = weight | |
__ @, "service", "sayHello", "url://..." | |
sayHello:-> | |
console.log "Hello #{@name}" | |
__ @, "service", "weight", "http://www.k33g.org?weight" | |
weight:-> | |
console.log weight | |
console.log '-----------------------------------------------' | |
console.log Human.annotations.Model.constructor | |
console.log Human.annotations["service"]["sayHello"] | |
console.log Human.annotations.service.weight | |
console.log Human.annotations.gui.fields | |
console.log '-----------------------------------------------' | |
for m of Human.annotations | |
console.log Human.annotations[m] | |
console.log '-----------------------------------------------' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment