Sorting, filtering, and searching using the command pattern to apply a list of queries to a collection .

Notice the `noop_call` method is returned when the criteria for a command is not met, returning the untouched collection to continue the chain of commands.

The command pattern is a design pattern used to store the information necessary to call methods at a future time. The queries array of lambdas are queued up before being applied to the collection using inject.

The resulting refactoring is change friendly but could be taken further to reduce churn of this file - extracting the sorting query to a separate module for instance.

comments powered by Disqus

Contact You wont find me on social networks (because I'm not there).