mirror of
https://github.com/samsonjs/grape-active_model_serializers.git
synced 2026-03-25 08:45:55 +00:00
Ensure support for Sequel models and datasets.
This commit is contained in:
parent
2748d5ba2b
commit
ed5d5b4ca4
1 changed files with 7 additions and 4 deletions
|
|
@ -48,8 +48,9 @@ module Grape
|
|||
end
|
||||
|
||||
def collection_class
|
||||
return nil unless resource.respond_to?(:to_ary)
|
||||
ActiveModel::Serializer.config.collection_serializer
|
||||
if resource.respond_to?(:to_ary) || resource.respond_to?(:all)
|
||||
ActiveModel::Serializer.config.collection_serializer
|
||||
end
|
||||
end
|
||||
|
||||
def namespace_inferred_class
|
||||
|
|
@ -84,8 +85,10 @@ module Grape
|
|||
end
|
||||
|
||||
def resource_class
|
||||
if resource.respond_to?(:to_ary)
|
||||
resource.try(:klass) || resource.compact.first.class
|
||||
if resource.respond_to?(:klass)
|
||||
resource.klass
|
||||
elsif resource.respond_to?(:to_ary) || resource.respond_to?(:all)
|
||||
resource.first.class
|
||||
else
|
||||
resource.class
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue