Skip to content

Commit

Permalink
Ensure support for Sequel models and datasets.
Browse files Browse the repository at this point in the history
  • Loading branch information
drn committed Apr 23, 2017
1 parent 2748d5b commit ed5d5b4
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions lib/grape-active_model_serializers/serializer_resolver.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ def resource_defined_class
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
Expand Down Expand Up @@ -84,8 +85,10 @@ def resource_namespace
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
Expand Down

0 comments on commit ed5d5b4

Please sign in to comment.