CachingPresenter is a very small presenter pattern implementation in Ruby. In short, the presenter pattern is a technique used to separate presentation logic (aka display logic or view logic) from domain logic and from the view templates themselves. There are a number of reasons this pattern is beneficial when used:
- it stops presentation logic from creeping into domain objects and muddying up their implementation and their business logic
- it stops unnecessary logic from creeping into the views themselves which should be as simple, flexible, and changeable as possible
- it allows you to organize presentation logic in better ways than simply maintaining helper modules that are included everywhere
CachingPresenter seems to be benefit most web-based projects where there is benefit from a separation between the view templates and corresponding presentation logic. It works superbly with Rails, but it is not dependent on Rails. You can use it for any ruby project, web-based or not.
Recent Changes
:requiring is removed in favor of :accepts
The :requiring option has been removed in favor of :accepts. This allows all additional arguments to be optional. For example:
Liquid error: No such file or directory - posix_spawnp
Caches hash-reader methods
If a presenter defines the #[] method or if what is being presented on responds to the
[] methods all calls to the presenter using hash-like accessors will successfully be
cached. Previously this would die.
Liquid error: No such file or directory - posix_spawnp
Does not try to cache writer methods
Usually you don’t use writer methods on presenters, but every now and then there is a good reason. Previously, CachingPresenter would completely fail if you writer to define an writer method, now it doesn’t. And it will successfully not be cached.
Liquid error: No such file or directory - posix_spawnp
Questions / Docs / Contact / Etc
Any questions, checkout the github page and its corresponding wiki . If all else fails let me know, zach dot dennis at gmail dot com
blog comments powered by Disqus