Skip to content

Instantly share code, notes, and snippets.

@swannodette
Last active January 1, 2016 20:59
Show Gist options
  • Save swannodette/8200979 to your computer and use it in GitHub Desktop.
Save swannodette/8200979 to your computer and use it in GitHub Desktop.
(ns example)
(defrecord HTTPRequest [type url proxy])
(HTTPRequest/getBasis)
;; =>
;; [type url proxy]
(defrecord HTTPProxy [host port])
(map->HTTPRequest
{:type :get
:url "http://example.org"
:proxy (HTTPProxy. "foo" 11111)})
;; =>
;; #example.HTTPRequest{
;; :type :get,
;; :url "http://example.org",
;; :proxy #example.HTTPProxy{:host "foo", :port 11111}
;; }
(:proxy
(map->HTTPRequest
{:type :get
:url "http://example.org"
:proxy (HTTPProxy. "foo" 11111)}))
;; =>
;; #example.HTTPProxy{:host "foo", :port 11111}
(keys
(map->HTTPRequest
{:type :get
:url "http://example.org"
:proxy (HTTPProxy. "foo" 11111)}))
;; =>
;; (:type :url :proxy)
((juxt :url :proxy)
(map->HTTPRequest
{:type :get
:url "http://example.org"
:proxy (HTTPProxy. "foo" 11111)}))
;; =>
;; ["http://example.org" #example.HTTPProxy{:host "foo", :port 11111}]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment