Skip to content

Commit

Permalink
Merge branch 'master' of github.com:jcasimir/draper
Browse files Browse the repository at this point in the history
  • Loading branch information
jcasimir committed Nov 30, 2011
2 parents 5e58b82 + 524fc97 commit 58a733e
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/draper/decorated_enumerable_proxy.rb
Expand Up @@ -26,6 +26,10 @@ def ==(other)
@wrapped_collection == other
end

def [](index)
@klass.new(@wrapped_collection[index], @context)
end

def to_s
"#<DecoratedEnumerableProxy of #{@klass} for #{@wrapped_collection.inspect}>"
end
Expand Down
6 changes: 6 additions & 0 deletions spec/draper/base_spec.rb
Expand Up @@ -310,6 +310,12 @@ module Paginator; def page_number; "magic_value"; end; end
subject_one.should_not == subject_two
end

it "should allow decorated access by index" do
subject = ProductDecorator.decorate(paged_array)

subject[0].should be_instance_of ProductDecorator
end

context '#all' do
it "should return a decorated collection" do
ProductDecorator.all.first.should be_instance_of ProductDecorator
Expand Down

0 comments on commit 58a733e

Please sign in to comment.