mirror of
https://github.com/drapergem/draper
synced 2023-03-27 23:21:17 -04:00
Support for Sequel
This commit is contained in:
parent
e4319afdf3
commit
ace6a0eb03
4 changed files with 20 additions and 1 deletions
|
@ -136,7 +136,7 @@ module Draper
|
|||
if input.instance_of?(self)
|
||||
input.options = options unless options.empty?
|
||||
return input
|
||||
elsif input.respond_to?(:each)
|
||||
elsif input.is_a?(Enumerable)
|
||||
Draper::DecoratedEnumerableProxy.new(input, self, options)
|
||||
elsif options[:infer]
|
||||
input.decorator(options)
|
||||
|
|
|
@ -363,6 +363,15 @@ describe Draper::Base do
|
|||
end
|
||||
end
|
||||
|
||||
context "when given a collection of objects which respond to #each" do
|
||||
# Sequel models implement #each
|
||||
let(:source) { [SequelProduct.new, SequelProduct.new] }
|
||||
|
||||
it "returns a collection of wrapped objects" do
|
||||
subject.each{ |decorated| decorated.should be_instance_of(Draper::Base) }
|
||||
end
|
||||
end
|
||||
|
||||
context "when given a single source object" do
|
||||
let(:source) { Product.new }
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@ require './spec/support/samples/namespaced_product_decorator'
|
|||
require './spec/support/samples/non_active_model_product'
|
||||
require './spec/support/samples/product'
|
||||
require './spec/support/samples/product_decorator'
|
||||
require './spec/support/samples/sequel_product'
|
||||
require './spec/support/samples/specific_product_decorator'
|
||||
require './spec/support/samples/some_thing'
|
||||
require './spec/support/samples/some_thing_decorator'
|
||||
|
|
9
spec/support/samples/sequel_product.rb
Normal file
9
spec/support/samples/sequel_product.rb
Normal file
|
@ -0,0 +1,9 @@
|
|||
class SequelProduct
|
||||
def each
|
||||
end
|
||||
|
||||
def some_attribute
|
||||
"hello"
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in a new issue