Merge pull request #629 from janko-m/collection-object-public
Make Draper::CollectionDecorator#object public
This commit is contained in:
commit
3e8f1a1fef
|
@ -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)
|
||||
|
|
|
@ -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])
|
||||
|
|
Loading…
Reference in New Issue