Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ArraySerializer#object like Serializer #1079

Merged
merged 1 commit into from
Sep 3, 2015

Conversation

bf4
Copy link
Member

@bf4 bf4 commented Aug 24, 2015

Useful for adapters that need access to the collection the ArraySerializer
is serializing. e.g.

resources = serializer.instance_variable_get(:@resource)
@hash[:links] = add_pagination_links(links, resources, options) if is_paginated?(resources)

  resources = serializer.instance_variable_get(:@resource)
  @hash[:links] = add_pagination_links(links, resources, options) if is_paginated?(resources)
end

def add_pagination_links(links, resources, options)
  pagination_links = JsonApi::PaginationLinks.new(resources, options[:context]).serializable_hash(options)

would become

  @hash[:links] = add_pagination_links(links, options)
end

def add_pagination_links(links, options)
  resources = serializer.object
  return links unless is_paginated?(resources)
  pagination_links = JsonApi::PaginationLinks.new(resources, options[:context]).serializable_hash(options)

@bf4 bf4 force-pushed the all_serializer_have_object branch from 7dca62e to dc4ee94 Compare August 24, 2015 18:51
@bacarini
Copy link
Contributor

👍

@bf4
Copy link
Member Author

bf4 commented Aug 26, 2015

@joaomdmoura don't forget about me :( :)

@@ -3,23 +3,22 @@ class Serializer
class ArraySerializer
NoSerializerError = Class.new(StandardError)
include Enumerable
delegate :each, to: :@objects
delegate :each, to: :@serializers
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@joaomdmoura
Copy link
Member

@joaomdmoura don't forget about me :( :)

How could I? Never! Merging this, nice!

joaomdmoura added a commit that referenced this pull request Sep 3, 2015
Add ArraySerializer#object like Serializer
@joaomdmoura joaomdmoura merged commit 6784866 into rails-api:master Sep 3, 2015
@bf4 bf4 deleted the all_serializer_have_object branch June 14, 2016 02:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants