Skip to content

Commit

Permalink
Add my own understanding to Presenter
Browse files Browse the repository at this point in the history
  • Loading branch information
ywen2 committed Apr 10, 2012
1 parent 4029667 commit 0991a30
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions README.md
Expand Up @@ -8,6 +8,16 @@ The presenter puts more emphasis on JSON representation of a business model obje

The gem is not trying to provide a automagic way to look cool. Rather, it focuses on explicitly expressing the intent of a Presenter class. Please read the usage for the details

## What is a presenter

A presenter is a bridge between a business model and how it will be presented (as json, as HTML, as text, as PDF, etc.). A presenter covers logic that is necessary for presenting a business model, but such logic should not be put into the business model because it doesn't belong to.

For example, what attributes are going to be included in the JSON return is not a business model's concern. Another example, If the front end needs to have a person's gender in a humanly readable way (such as "Male" and "Female"), it is not the business model's concern. The business model knows it's gender in some way, it might choose to represent it as a boolean ```model.male?``` and ```model.female?```. It is the responsibility of a presenter to provide what the front end needs. The Presenter may return the string ```Male``` or ```Female``` in its ```gender``` method.

## What is not a presenter

A presenter is a Ruby class, it is not a place for generating HTML tags and even strings. An HTML file is the place for writing HTML code.

## Installation

Add this line to your application's Gemfile:
Expand Down

0 comments on commit 0991a30

Please sign in to comment.