Alias Model.decorator to Model.decorate

This commit is contained in:
Jeff Casimir 2011-10-28 21:14:02 -04:00
parent 0893f1f813
commit 77a6510b6e
2 changed files with 6 additions and 2 deletions

View File

@ -3,6 +3,8 @@ module Draper::ModelSupport
@decorator ||= "#{self.class.name}Decorator".constantize.decorate(self)
block_given? ? yield(@decorator) : @decorator
end
alias :decorate :decorator
module ClassMethods
def decorate(context = {})

View File

@ -11,6 +11,10 @@ describe Draper::ModelSupport do
a = Product.new.decorator { |d| d.awesome_title }
a.should eql "Awesome Title"
end
it 'should be aliased to .decorate' do
subject.decorator.model.should == subject.decorate.model
end
end
describe '#decorate - decorate collections of AR objects' do
@ -21,7 +25,5 @@ describe Draper::ModelSupport do
subject.decorate.size.should == 1
subject.decorate.to_ary[0].model.should be_a(Product)
end
end
end