1
0
Fork 0
mirror of https://github.com/drapergem/draper synced 2023-03-27 23:21:17 -04:00

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

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

View file

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