active_model_serializers

https://github.com/rails-api/active_model_serializers

Ruby

ActiveModel::Serializer implementation and Rails hooks

ActiveModel::Serializer::CollectionSerializer#json_key

TODO: unify naming of root, json_key, and _type.  Right now, a serializer's
json_key comes from the root option or the object's model name, by default.
But, if a dev defines a custom `json_key` method with an explicit value,
we have no simple way to know that it is safe to call that instance method.
(which is really a class property at this point, anyhow).
rubocop:disable Metrics/CyclomaticComplexity
Disabling cop since it's good to highlight the complexity of this method by
including all the logic right here.

Source | Google | Stack overflow

Edit

git clone [email protected]:rails-api/active_model_serializers.git

cd active_model_serializers

open lib/active_model/serializer/collection_serializer.rb

Contribute

# Make a new branch

git checkout -b -your-name--update-docs-ActiveModel--Serializer--CollectionSerializer-json_key-for-pr


# Commit to git

git add lib/active_model/serializer/collection_serializer.rbgit commit -m "better docs for ActiveModel::Serializer::CollectionSerializer#json_key"


# Open pull request

gem install hub # on a mac you can `brew install hub`

hub fork

git push <your name> -your-name--update-docs-ActiveModel--Serializer--CollectionSerializer-json_key-for-pr

hub pull-request


# Celebrate!