`with-defaults` isn’t working
iamdustan opened this issue · comments
Hey @Raynes,
First off: this project is great.
I’m still very new to clojure so I may be doing something wrong, but with-defaults
doesn’t seem to be working for me. (Side note: the first entry in every API response is always an empty hash for me...)
Example:
(ns project.repl
(:require [tentacles.core :as t]
[tentacles.orgs :as orgs]))
(def defaults { :oauth-token "LOOK_ITS_MAH_TOKEN"
:per-page 100 })
;; I assume this should automatically merge these defaults with any provided options for every API request
(t/with-defaults defaults)
;; so this request should have my authorization token and return private teams
(defn teams [org]
(orgs/teams org))
(teams "skookum") ;; -> only public teams
;; so I have to manually pass in the options object to get private teams
(defn teams-manual-defaults [org]
(orgs/teams org defaults))
(teams-manual-defaults "skookum") ;; -> all teams
with-defaults
binds defaults within its scope -- you have to put all code that is meant to see those defaults inside of the with-defaults
call.
(with-defaults defaults (teams "skookum"))
ah shucks. Is there any way to make an application global specific set of defaults?
No, you don't often want that in Clojure.
Blasted side effects! 😄
I know, right? How dare this not be a GithubAPI class. ;)
—
Sent from Mailbox
On Wed, Nov 5, 2014 at 12:27 PM, Dustan Kasten notifications@github.com
wrote:
Blasted side effects! 😄
Reply to this email directly or view it on GitHub:
#60 (comment)