File tree 2 files changed +21
-3
lines changed
2 files changed +21
-3
lines changed Original file line number Diff line number Diff line change 160
160
([x path]
161
161
(path-meta x path nil ))
162
162
([x path query]
163
- (let [x' (cond->> x
164
- (map? x) (into {} (map (fn [[k v]] [k (path-meta v (conj path k))])))
165
- (vector? x) (into [] (map-indexed #(path-meta %2 (conj path %1 )))))]
163
+ (let [x' (cond
164
+ (record? x) x
165
+ (map? x) (into {} (map (fn [[k v]] [k (path-meta v (conj path k))]) x))
166
+ (vector? x) (into [] (map-indexed #(path-meta %2 (conj path %1 )) x))
167
+ :else x)]
166
168
(cond-> x'
167
169
#?(:clj (instance? clojure.lang.IObj x')
168
170
:cljs (satisfies? IWithMeta x'))
Original file line number Diff line number Diff line change 368
368
{:value v}
369
369
{:remote true }))
370
370
371
+ (defmethod read :location
372
+ [{:keys [state]} k params]
373
+ (if-let [v (get @state k)]
374
+ {:value v}
375
+ {:remote true }))
376
+
371
377
(defmethod read :woz/noz
372
378
[{:keys [state]} k params]
373
379
(if-let [v (get @state k)]
404
410
(is (= (p {:state st} [:foo/bar ] :remote ) []))
405
411
(is (= (p {:state st} [:foo/bar :baz/woz ] :remote ) [:baz/woz ]))))
406
412
413
+ (defrecord Point [lat lon])
414
+
415
+ (deftest test-parse-defrecord
416
+ (let [location (->Point 1 2 )
417
+ state (atom {:location location})
418
+ result (p {:state state} [:location ])]
419
+ (is (= result {:location location}))
420
+ (is (instance? Point (:location result)))
421
+ (is (= (meta result) {:om-path []}))))
422
+
407
423
(deftest test-value-and-remote
408
424
(let [st (atom {:woz/noz 1 })]
409
425
(is (= (p {:state st} [:woz/noz ]) {:woz/noz 1 }))
You can’t perform that action at this time.
0 commit comments