Skip to content

Commit

Permalink
Always serialize hashes for creators as lists of
Browse files Browse the repository at this point in the history
Related to datacite/lupo/282
This is to ensure we return creators as  lists as per schema.
  • Loading branch information
richardhallett committed May 27, 2019
1 parent 1f8f516 commit ae083e9
Show file tree
Hide file tree
Showing 2 changed files with 135 additions and 107 deletions.
9 changes: 9 additions & 0 deletions app/serializers/doi_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,15 @@ class DoiSerializer
object.doi.downcase
end

attribute :creators do |object|
# If we're just a hash then force this over to a list.
if object.creators.class == Hash

This comment has been minimized.

Copy link
@mfenner

mfenner May 27, 2019

Contributor

you can do Array.wrap(object.creators).

object.creators = [object.creators]
end

object.creators
end

attribute :state do |object|
object.aasm_state
end
Expand Down
Loading

0 comments on commit ae083e9

Please sign in to comment.