Skip to content

Instantly share code, notes, and snippets.

@myfit
Created March 2, 2010 11:15
Show Gist options
  • Save myfit/319438 to your computer and use it in GitHub Desktop.
Save myfit/319438 to your computer and use it in GitHub Desktop.
(defn call-method [method params]
...POST request...)
(defn apify-method [call-sym]
(let [call (name call-sym)
call-sp (.split call "-")
class (first call-sp)
method1 (first (rest call-sp))
method (if (< 1 (count call-sp))
(rest (rest call-sp)) ())]
(format
"%s.%s%s"
class
method1
(string/join ""
(map string/capitalize method)))))
(defmacro define-method [method args]
`(defn ~method ~args
(call-method ~(format "facebook.%s" (apify-method method))
~(zipmap
(map
#(keyword (name %))
args)
args))))
(define-method my-complex-method [my_arg_name])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment