Skip to content

Commit

Permalink
change field-spec-of to force 'type' and allow entity-or-type as argu…
Browse files Browse the repository at this point in the history
…ment

This change is needed for references.  When using get-reference, grab, grab-in
you pass the entity and those functions use 'field-spec-of' to get the correct document.
'field-spec-of' returned nil because entity was being sent not type.
  • Loading branch information
sethtrain committed Nov 23, 2010
1 parent 03f0fef commit 503ed2e
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/karras/entity.clj
Expand Up @@ -139,10 +139,11 @@ Example:
(class entity-or-type)))

(defn field-spec-of
"Given a type and one or more keys,
"Given a type or entity and one or more keys,
returns the field spec for the last key."
[type & keys]
(let [field-type (or (reduce (fn [t k]
[entity-or-type & keys]
(let [type (get-type entity-or-type)
field-type (or (reduce (fn [t k]
(-> t entity-spec :fields k :type))
type
(butlast keys))
Expand Down

0 comments on commit 503ed2e

Please sign in to comment.