Skip to content

Commit

Permalink
Refactor map predicate.
Browse files Browse the repository at this point in the history
  • Loading branch information
David Frese committed Oct 17, 2024
1 parent bb02f88 commit f89b6cc
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/active/data/realm.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,11 @@ The two-argument version can be called as follows:
realm-records/predicate map?
realm-records/metadata {})))

(defn- map-with-tag-predicate [key value]
(fn [x]
(and (map? x)
(= (get x key nil) value))))

(defn map-with-tag
"Create realm for maps containing a tag.
Expand All @@ -412,10 +417,7 @@ The two-argument version can be called as follows:
realm-records/description (str "map with tag " key " -> " value)
realm-records/map-with-tag-realm-key key
realm-records/map-with-tag-realm-value value
realm-records/predicate
(fn [x]
(and (map? x)
(= (get x key nil) value)))
realm-records/predicate (map-with-tag-predicate key value)
realm-records/metadata {}))

(defn tuple
Expand Down

0 comments on commit f89b6cc

Please sign in to comment.