Merge pull request #109 from arohner/master

Fix for issue 716, :map-ebs-snapshot-to-device-name
This commit is contained in:
Adrian Cole 2011-10-13 01:52:18 -07:00
commit c84a1037e3
3 changed files with 13 additions and 2 deletions

View File

@ -399,8 +399,8 @@ See http://code.google.com/p/jclouds for details."
;; aws ec2 options
:map-ephemeral-device-to-device-name])
{:map-ebs-snapshot-to-device-name
(kw-memfn-apply :map-ebs-snapshot-to-device-name
device-name snapshot-id size-in-gib delete-on-termination)
(memfn-apply mapEBSSnapshotToDeviceName
device-name snapshot-id size-in-gib delete-on-termination)
:map-new-volume-to-device-name
(kw-memfn-apply :map-new-volume-to-device-name
device-name size-in-gib delete-on-termination)}))

View File

@ -94,6 +94,12 @@ Ensure the module is on the classpath. You are maybe missing a dependency on
[kw]
(symbol (camelize-mixed kw)))
(defmacro memfn-apply
"Expands into a function that takes one argument,"
[fn-name & args]
`(fn [target# [~@args]]
((memfn ~fn-name ~@args) target# ~@args)))
(defmacro kw-memfn
"Expands into code that creates a function that expects to be passed an
object and any args, and calls the instance method corresponding to

View File

@ -55,6 +55,11 @@ list, Alan Dipert and MeikelBrandmeyer."
(deftest kw-fn-symbol-test
(is (= 'aB (kw-fn-symbol :a-b))))
(deftest memfn-apply-test
(is (= "Ab" ((memfn-apply concat s) "A" ["b"])))
(is (= "Ac" ((memfn-apply replace a b) "Ab" ["b" "c"]))))
(deftest kw-memfn-test
(is (= "a" ((kw-memfn :to-lower-case) "A")))
(is (= "Ab" ((kw-memfn :concat s) "A" "b")))