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:
parent
0893f1f813
commit
77a6510b6e
2 changed files with 6 additions and 2 deletions
|
@ -3,6 +3,8 @@ module Draper::ModelSupport
|
||||||
@decorator ||= "#{self.class.name}Decorator".constantize.decorate(self)
|
@decorator ||= "#{self.class.name}Decorator".constantize.decorate(self)
|
||||||
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 = {})
|
||||||
|
|
|
@ -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
|
||||||
|
|
Loading…
Reference in a new issue