golo-lang/golo-lang — pull request #115 by k33g (2013-12-12 17:18:39+00:00)
Title: Add hasMethod to DynamicObject

a handy little helper,
Sometimes, it is interesting to know whether a DynamicObject has a method or not :

Today, i have to do that :

let isUpdatable = |object| {
let properties = object: properties(): filter(|property|-> property: getKey(): equals("update"))
if properties: size(): equals(1) {
return isClosure(properties :iterator(): next(): getValue())
} else {
return false
}
}

isUpdatable(DynamicObject(): define("update", |this| -> "foo"))

And now, I could do it like this :

(DynamicObject(): define("update", |this| -> "foo")): hasMethod("update")