lib/onsi/resource.rb in onsi-1.3.1 vs lib/onsi/resource.rb in onsi-2.0.1
- old
+ new
@@ -1,6 +1,7 @@
require_relative 'errors'
+require_relative 'paginate'
module Onsi
##
# The wrapper for generating a object
#
@@ -69,10 +70,12 @@
# @return [Onsi::Resource, Array<Onsi::Resource>]
def as_resource(resource, version)
case resource
when Onsi::Resource
resource
+ when Onsi::Paginate::Result
+ as_resource(resource.query, version)
when Enumerable
resource.map { |res| as_resource(res, version) }
else
Onsi::Resource.new(resource, version)
end
@@ -95,9 +98,12 @@
if included.any?
root[INCLUDED_KEY] = included
end
root[META_KEY] = {}.tap do |meta|
meta[:count] = resources.count if resources.respond_to?(:count)
+ if resource.is_a?(Onsi::Paginate::Result)
+ meta[:pagination] = resource.params
+ end
end
end
end
private