Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Draper - Visnupriya - spriteXchange


Published on

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

Published in: Technology
  • Be the first to comment

  • Be the first to like this

Draper - Visnupriya - spriteXchange

  1. 1. Draper Decorators/View-Models for Rails Applications Visnupriya. J .R 7th April 2014 @visnupriya90| © Spritle Software Private Limited |
  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 |
  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 |
  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 |
  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 |
  6. 6. SAMPLE CODE Time to wakeup © Spritle Software Private Limited |
  7. 7. Questions? Thank you © Spritle Software Private Limited |