mirror of
https://github.com/samsonjs/grape-active_model_serializers.git
synced 2026-04-27 14:57:43 +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,9 +48,10 @@ module Grape
|
||||||
end
|
end
|
||||||
|
|
||||||
def collection_class
|
def collection_class
|
||||||
return nil unless resource.respond_to?(:to_ary)
|
if resource.respond_to?(:to_ary) || resource.respond_to?(:all)
|
||||||
ActiveModel::Serializer.config.collection_serializer
|
ActiveModel::Serializer.config.collection_serializer
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def namespace_inferred_class
|
def namespace_inferred_class
|
||||||
return nil unless options.key?(:for)
|
return nil unless options.key?(:for)
|
||||||
|
|
@ -84,8 +85,10 @@ module Grape
|
||||||
end
|
end
|
||||||
|
|
||||||
def resource_class
|
def resource_class
|
||||||
if resource.respond_to?(:to_ary)
|
if resource.respond_to?(:klass)
|
||||||
resource.try(:klass) || resource.compact.first.class
|
resource.klass
|
||||||
|
elsif resource.respond_to?(:to_ary) || resource.respond_to?(:all)
|
||||||
|
resource.first.class
|
||||||
else
|
else
|
||||||
resource.class
|
resource.class
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue