Draper
Decorators/View-Models for Rails Applications
Visnupriya. J .R
7th April 2014
@visnupriya90| github.com/visnupriya
...
What is Draper?
• object-oriented layer of presentation
logic to your Rails application.
• The idea of Draper is to provid...
Why use Draper?
• Clean up complex view logic
• Provides decorators which
bundles view logic in an object
oriented fashion...
What is Decorator Pattern?
• It is a design pattern.
• It allows behavior to be added to an
individual object, either stat...
Let’s see how to use?
• Add Draper to your Gemfile
• Generate decorator for a model as shown
below
• rails generate decora...
SAMPLE CODE
Time to wakeup
© Spritle Software Private Limited | http://www.spritle.com
Questions?
Thank you
© Spritle Software Private Limited | http://www.spritle.com
Upcoming SlideShare
Loading in …5
×

Draper - Visnupriya - spriteXchange

421 views
386 views

Published on

Draper, decorator, view decorators, Rails 3, Rails 4,

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
421
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
3
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Draper - Visnupriya - spriteXchange

  1. 1. Draper Decorators/View-Models for Rails Applications Visnupriya. J .R 7th April 2014 @visnupriya90| github.com/visnupriya © Spritle Software Private Limited | http://www.spritle.com
  2. 2. What is Draper? • object-oriented layer of presentation logic to your Rails application. • The idea of Draper is to provide real ruby class between the template and the model. • To decorate templates. © Spritle Software Private Limited | http://www.spritle.com
  3. 3. Why use Draper? • Clean up complex view logic • Provides decorators which bundles view logic in an object oriented fashion • Easy to test than helpers • Code readability and easy to maintain • Code reuse © Spritle Software Private Limited | http://www.spritle.com
  4. 4. What is Decorator Pattern? • It is a design pattern. • It allows behavior to be added to an individual object, either statically or dynamically, without affecting the behavior of other objects from the same class © Spritle Software Private Limited | http://www.spritle.com
  5. 5. Let’s see how to use? • Add Draper to your Gemfile • Generate decorator for a model as shown below • rails generate decorator Article © Spritle Software Private Limited | http://www.spritle.com
  6. 6. SAMPLE CODE Time to wakeup © Spritle Software Private Limited | http://www.spritle.com
  7. 7. Questions? Thank you © Spritle Software Private Limited | http://www.spritle.com

×