mirror of
https://github.com/drapergem/draper
synced 2023-03-27 23:21:17 -04:00
Cleaning up the merge that removes lazy_helpers method
This commit is contained in:
commit
6438829e3a
3 changed files with 1 additions and 18 deletions
|
@ -198,7 +198,7 @@ Hate seeing that `h.` proxy all over? Willing to mix a bazillion methods into yo
|
||||||
```ruby
|
```ruby
|
||||||
class ArticleDecorator < ApplicationDecorator
|
class ArticleDecorator < ApplicationDecorator
|
||||||
decorates :article
|
decorates :article
|
||||||
lazy_helpers
|
include Draper::LazyHelpers
|
||||||
|
|
||||||
def published_at
|
def published_at
|
||||||
date = content_tag(:span, model.published_at.strftime("%A, %B %e").squeeze(" "), :class => 'date')
|
date = content_tag(:span, model.published_at.strftime("%A, %B %e").squeeze(" "), :class => 'date')
|
||||||
|
|
|
@ -105,16 +105,6 @@ module Draper
|
||||||
end
|
end
|
||||||
alias :h :helpers
|
alias :h :helpers
|
||||||
|
|
||||||
# Calling `lazy_helpers` will make the built-in and
|
|
||||||
# user-defined Rails helpers accessible as class methods
|
|
||||||
# in the decorator without using the `h.` or `helpers.` proxy.
|
|
||||||
#
|
|
||||||
# The drawback is that you dump many methods into your decorator's
|
|
||||||
# namespace and collisions could create unexpected results.
|
|
||||||
def self.lazy_helpers
|
|
||||||
self.send(:include, Draper::LazyHelpers)
|
|
||||||
end
|
|
||||||
|
|
||||||
# Fetch the original wrapped model.
|
# Fetch the original wrapped model.
|
||||||
#
|
#
|
||||||
# @return [Object] original_model
|
# @return [Object] original_model
|
||||||
|
|
|
@ -26,13 +26,6 @@ describe Draper::Base do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context(".lazy_helpers") do
|
|
||||||
it "makes Rails helpers available without using the h. proxy" do
|
|
||||||
Draper::Base.lazy_helpers
|
|
||||||
subject.send(:pluralize, 5, "cat").should == "5 cats"
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
context(".decorates") do
|
context(".decorates") do
|
||||||
it "sets the model class for the decorator" do
|
it "sets the model class for the decorator" do
|
||||||
ProductDecorator.new(source).model_class.should == Product
|
ProductDecorator.new(source).model_class.should == Product
|
||||||
|
|
Loading…
Add table
Reference in a new issue