Merge pull request #629 from janko-m/collection-object-public

Make Draper::CollectionDecorator#object public
This commit is contained in:
Steve Klabnik 2014-10-29 13:15:28 -04:00
commit 3e8f1a1fef
2 changed files with 12 additions and 3 deletions

View File

@ -4,6 +4,9 @@ module Draper
include Draper::ViewHelpers
extend Draper::Delegation
# @return the collection being decorated.
attr_reader :object
# @return [Class] the decorator class used to decorate each item, as set by
# {#initialize}.
attr_reader :decorator_class
@ -79,9 +82,6 @@ module Draper
protected
# @return the collection being decorated.
attr_reader :object
# Decorates the given item.
def decorate_item(item)
item_decorator.call(item, context: context)

View File

@ -238,6 +238,15 @@ module Draper
end
end
describe '#object' do
it 'returns the underlying collection' do
collection = [Product.new]
decorator = ProductsDecorator.new(collection)
expect(decorator.object).to eq collection
end
end
describe '#decorated?' do
it 'returns true' do
decorator = ProductsDecorator.new([Product.new])