From 2d3c0839e9b4feb22d212605c49e9e3934384ec6 Mon Sep 17 00:00:00 2001 From: Mike Date: Sat, 8 Oct 2011 03:29:58 +0300 Subject: [PATCH 1/2] Encourage use of include keyword --- Readme.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Readme.markdown b/Readme.markdown index 0fe1f19..42bb4e0 100644 --- a/Readme.markdown +++ b/Readme.markdown @@ -196,7 +196,7 @@ Hate seeing that `h.` proxy all over? Willing to mix a bazillion methods into yo ```ruby class ArticleDecorator < ApplicationDecorator decorates :article - lazy_helpers + include Draper::LazyHelpers def published_at date = content_tag(:span, model.published_at.strftime("%A, %B %e").squeeze(" "), :class => 'date') From b3e38a43c49980f5688cd55e6534ad9d9924d511 Mon Sep 17 00:00:00 2001 From: Mike Date: Sat, 8 Oct 2011 03:40:18 +0300 Subject: [PATCH 2/2] include LazyHelpers without macro --- spec/base_spec.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/base_spec.rb b/spec/base_spec.rb index 32840b9..ee1d34a 100644 --- a/spec/base_spec.rb +++ b/spec/base_spec.rb @@ -5,9 +5,9 @@ describe Draper::Base do subject{ Draper::Base.new(source) } let(:source){ Product.new } - context(".lazy_helpers") do - it "makes Rails helpers available without using the h. proxy" do - Draper::Base.lazy_helpers + context("module LazyHelpers") do + it "makes Rails helpers available without using the h. proxy by including it" do + Draper::Base.send(:include, Draper::LazyHelpers) subject.send(:pluralize, 5, "cat").should == "5 cats" end end