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 157
157
key)))))))
158
158
159
159
(defn path-meta [x path]
160
- (let [x' (cond->> x
161
- (map? x) (into {} (map (fn [[k v]] [k (path-meta v (conj path k))])))
162
- (vector? x) (into [] (map-indexed #(path-meta %2 (conj path %1 )))))]
160
+ (let [x' (cond
161
+ (record? x) x
162
+ (map? x) (into {} (map (fn [[k v]] [k (path-meta v (conj path k))])) x)
163
+ (vector? x) (into [] (map-indexed #(path-meta %2 (conj path %1 ))) x)
164
+ :else x)]
163
165
(cond-> x'
164
166
#?(:clj (instance? clojure.lang.IObj x')
165
167
:cljs (satisfies? IWithMeta x'))
Original file line number Diff line number Diff line change 236
236
{:value v}
237
237
{:remote true }))
238
238
239
+ (defmethod read :location
240
+ [{:keys [state]} k params]
241
+ (if-let [v (get @state k)]
242
+ {:value v}
243
+ {:remote true }))
244
+
239
245
(defmethod read :woz/noz
240
246
[{:keys [state]} k params]
241
247
(if-let [v (get @state k)]
272
278
(is (= (p {:state st} [:foo/bar ] :remote ) []))
273
279
(is (= (p {:state st} [:foo/bar :baz/woz ] :remote ) [:baz/woz ]))))
274
280
281
+ (defrecord Point [lat lon])
282
+
283
+ (deftest test-parse-defrecord
284
+ (let [location (->Point 1 2 )
285
+ state (atom {:location location})
286
+ result (p {:state state} [:location ])]
287
+ (is (= result {:location location}))
288
+ (is (instance? Point (:location result)))
289
+ (is (= (meta result) {:om-path []}))))
290
+
275
291
(deftest test-value-and-remote
276
292
(let [st (atom {:woz/noz 1 })]
277
293
(is (= (p {:state st} [:woz/noz ]) {:woz/noz 1 }))
You can’t perform that action at this time.
0 commit comments