lib/finix/pagination.rb in finix-0.7 vs lib/finix/pagination.rb in finix-0.8
- old
+ new
@@ -47,13 +47,11 @@
def create(attrs={})
attrs = attrs.attributes if attrs.is_a?(Finix::Resource)
attrs = Finix::Utils.indifferent_read_access attrs
href = @hyperlinks[:self]
- if @resource_class.nil?
- @resource_class = Finix.from_href(href)
- end
+ @resource_class = Finix.from_hypermedia_registry href, attrs
@resource_class.new(attrs, href).save
end
private
@@ -68,10 +66,13 @@
@attributes = {} # clear attributes
if body.has_key? '_embedded'
resource_name, resources = body.delete('_embedded').first
@resource_class = Finix.from_hypermedia_registry resource_name
- @attributes['items'] = resources.map { |item| @resource_class.construct_from_response item }
+ @attributes['items'] = resources.map do |attrs|
+ cls = Finix.from_hypermedia_registry resource_name, attrs
+ cls.construct_from_response attrs
+ end
@attributes['page'] = body.delete('page')
end
end
end
\ No newline at end of file