Architectural decisions
Why does it look like a mailer?
Coupdoeil::Popover
implementation is inspired from ActionMailer::Base
, as it also inherits from AbstractController::Base
(see controller features). It borrows mailer architecture because it allows easily using different templates for the same resource but for different contexts. It does so by using .with
method directly inspired from Action Mailer Parameterized.
Why aren’t partials located within the views folder if it looks like a mailer?
Actually, you can if you want, it is just a default choice so the popovers files are grouped together. Go for it if you prefer this way. If you think this should be the default, please open an issue to share your opinion. Early design was actually putting popover partials in views folder, but during development and usage documentation it felt more natural to move it to app/popovers
.
Why a ‘coupdoeil_popover_tag’ helper and no ‘render’?
Another type of inclusion in HTML was tried at first, like:
<%# app/views/messages/show.html.erb %>
<%= render ContactPopover.with(contact: @contact).tag do %>
<p><%= @contact.full_name %></p>
<% end %>
but because Coupdoeil is intended to do more than just popover it was not kept. Soon will be added the possibility to easily handle side-peek views (also called drawers). Perhaps also modals. With this feature added, the “Coupdoeil” (sneak-peek) concept carried by this gem will be completed. The connection with the helper is that to allow both popover and side peek on the same link (for example) a more global coupdoeil_tag
helper will be used (more to be disclosed soon … hopefully).
What does Coupdoeil mean?
Coupdoeil (phonetically “koo-doy”) comes from the French expression “coup d’œil” which translates to “a glance” or “a peek,” matching the intent of this gem to facilitate “quick looks.”