Skip to content

Commit

Permalink
Add example for :after :default to the README (#146)
Browse files Browse the repository at this point in the history
* Add example for `:after :default` to the README

* fix spelling in comments
  • Loading branch information
escherize authored Jan 3, 2024
1 parent ff27c86 commit f78c5a1
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,10 @@ the last argument of the next function:
;; -> [:default :object :string]
```

An example usecase for `:after` is chess. When looking up legal moves, you
implement how each piece can move, then in `:after :default` limit it to only
spaces on the board.

#### `:around` methods

`:around` methods are called around all other methods and give you the power to choose how or when to invoke those
Expand Down
2 changes: 1 addition & 1 deletion src/methodical/interface.clj
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
dispatch value, existing implementations of `MethodTable` are currently only able to remove exact matches -- for
functions, this usually means identical objects.
In the future, I hope to fix this by storing unique indentifiers in the metadata of methods in the map."))
In the future, I hope to fix this by storing unique identifiers in the metadata of methods in the map."))

(defprotocol Dispatcher
"A *dispatcher* decides which dispatch value should be used for a given set of arguments, which primary and
Expand Down
4 changes: 2 additions & 2 deletions test/methodical/util_test.clj
Original file line number Diff line number Diff line change
Expand Up @@ -374,12 +374,12 @@
(u/add-aux-method-with-unique-key! #'unique-key-multifn :before ::key #(conj % :before) "Florida key")
(t/is (= 1
(count (u/aux-methods unique-key-multifn :before ::key)))
"should be able to desctructively add an aux method with a unique key")
"should be able to destructively add an aux method with a unique key")

(u/remove-aux-method-with-unique-key! #'unique-key-multifn :before ::key "Florida key")
(t/is (= 0
(count (u/aux-methods unique-key-multifn :before ::key)))
"should be able to desctructively remove an aux method with a unique key")))
"should be able to destructively remove an aux method with a unique key")))

(t/deftest remove-all-methods-test
(let [f (-> (m/default-multifn class)
Expand Down

0 comments on commit f78c5a1

Please sign in to comment.