mirror of
https://github.com/drapergem/draper
synced 2023-03-27 23:21:17 -04:00
added context to enumerable
This commit is contained in:
parent
15992b8e34
commit
f9f0982cd9
2 changed files with 9 additions and 0 deletions
|
@ -38,6 +38,10 @@ module Draper
|
|||
def to_s
|
||||
"#<DecoratedEnumerableProxy of #{@klass} for #{@wrapped_collection.inspect}>"
|
||||
end
|
||||
|
||||
def context=(input)
|
||||
self.map { |member| member.context = input }
|
||||
end
|
||||
|
||||
def source
|
||||
@wrapped_collection
|
||||
|
|
|
@ -313,6 +313,11 @@ describe Draper::Base do
|
|||
it "returns a collection of wrapped objects" do
|
||||
subject.each{ |decorated| decorated.should be_instance_of(Draper::Base) }
|
||||
end
|
||||
|
||||
it 'should accepted and store a context for a collection' do
|
||||
subject.context = :admin
|
||||
subject.each { |decorated| decorated.context.should == :admin }
|
||||
end
|
||||
end
|
||||
|
||||
context "when given a single source object" do
|
||||
|
|
Loading…
Reference in a new issue