added context to enumerable
This commit is contained in:
parent
15992b8e34
commit
f9f0982cd9
|
@ -39,6 +39,10 @@ module Draper
|
||||||
"#<DecoratedEnumerableProxy of #{@klass} for #{@wrapped_collection.inspect}>"
|
"#<DecoratedEnumerableProxy of #{@klass} for #{@wrapped_collection.inspect}>"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def context=(input)
|
||||||
|
self.map { |member| member.context = input }
|
||||||
|
end
|
||||||
|
|
||||||
def source
|
def source
|
||||||
@wrapped_collection
|
@wrapped_collection
|
||||||
end
|
end
|
||||||
|
|
|
@ -313,6 +313,11 @@ describe Draper::Base do
|
||||||
it "returns a collection of wrapped objects" do
|
it "returns a collection of wrapped objects" do
|
||||||
subject.each{ |decorated| decorated.should be_instance_of(Draper::Base) }
|
subject.each{ |decorated| decorated.should be_instance_of(Draper::Base) }
|
||||||
end
|
end
|
||||||
|
|
||||||
|
it 'should accepted and store a context for a collection' do
|
||||||
|
subject.context = :admin
|
||||||
|
subject.each { |decorated| decorated.context.should == :admin }
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when given a single source object" do
|
context "when given a single source object" do
|
||||||
|
|
Loading…
Reference in New Issue