Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
:license {:name "The MIT License"
:url "http://opensource.org/licenses/MIT"}
:dependencies [[com.stuartsierra/dependency "1.0.0"]
[org.clojure/clojure "1.7.0" :scope "provided"]])
[org.clojure/clojure "1.11.0" :scope "provided"]])
10 changes: 3 additions & 7 deletions src/com/stuartsierra/component.cljc
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@
(-write writer "#<SystemMap>"))))

(defn system-map
"Returns a system constructed of key/value pairs. The system has
"Returns a system constructed of key/value pairs or a map. The system has
default implementations of the Lifecycle 'start' and 'stop' methods
which recursively start/stop all components in the system.
Expand All @@ -205,12 +205,8 @@
'read'. To disable this behavior and print system maps like normal
records, call
(remove-method clojure.core/print-method com.stuartsierra.component.SystemMap)"
[& keyvals]
;; array-map doesn't check argument length (CLJ-1319)
(when-not (even? (count keyvals))
(throw (platform/argument-error
"system-map requires an even number of arguments")))
(map->SystemMap (apply array-map keyvals)))
[& {:as sys-map}]
(map->SystemMap sys-map))

(defn subsystem
"Returns a system containing only components associated with the keys
Expand Down
8 changes: 8 additions & 0 deletions test/com/stuartsierra/component_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,14 @@
(let [system (component/start (system-2))]
(is (started? (get-in system [:beta :one :d :my-c])))))


(deftest map->system
(let [system (component/start (component/system-map {:a (component-a)
:b (component-b)}))]
(is (started? (get-in system [:a])))
(is (started? (get-in system [:b])))))


(defn increment-all-components [system]
(component/update-system
system (keys system) update-in [:n] inc))
Expand Down