Skip to content

Commit

Permalink
Sensible defaults for instantiate-record-from
Browse files Browse the repository at this point in the history
  • Loading branch information
ZackGC authored and michaelklishin committed Sep 14, 2012
1 parent f769c86 commit 13643f5
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/clojure/clojurewerkz/neocons/rest/records.clj
Original file line number Diff line number Diff line change
Expand Up @@ -137,13 +137,16 @@


(defn instantiate-record-from
"Instantiates a record from the given payload, detecting what kind of Neo4J entity (a node, a relationship,
a path) this payload represents"
"Instantiates a record from the given payload, detecting what kind
of Neo4J entity (a node, a relationship, a path) this payload
represents. Defaults to returning the object if we don't know how to
deal with it."
[payload]
(let [f (cond (:create_relationship payload) instantiate-node-from
(and (:type payload)
(:data payload)) instantiate-rel-from
(and (:start payload)
(:end payload)
(not (:type payload))) instantiate-path-from)]
(and (:start payload)
(:end payload)
(not (:type payload))) instantiate-path-from
:else identity)]
(f payload)))

0 comments on commit 13643f5

Please sign in to comment.