Skip to content

Commit

Permalink
feat: automatically mark id as an identifier (rendered first)
Browse files Browse the repository at this point in the history
  • Loading branch information
ElMassimo committed Apr 2, 2023
1 parent afd80ac commit c4c6de7
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/oj_serializers/serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,9 @@ def ams_attributes(*attr_names, **options)
private

def add_attribute(value_from, root: nil, as: nil, **options)
# Because it's so common, automatically mark id as an identifier.
options[:identifier] = true if value_from == :id && !options.key?(:identifier)

# Hash attributes could be numbers or symbols.
value_from = value_from.to_s unless options[:attribute] == :hash

Expand Down

0 comments on commit c4c6de7

Please sign in to comment.