active_model_serializers

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

Ruby

ActiveModel::Serializer implementation and Rails hooks

ActiveModel::Serializer#as_json

TODO: When moving attributes adapter logic here, @see #serializable_hash
So that the below is true:
  @param options [nil, Hash] The same valid options passed to `as_json`
     (:root, :only, :except, :methods, and :include).
  The default for `root` is nil.
  The default value for include_root is false. You can change it to true if the given
  JSON string includes a single root node.

Source | Google | Stack overflow

Edit

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

cd active_model_serializers

open lib/active_model/serializer.rb

Contribute

# Make a new branch

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


# Commit to git

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


# 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-as_json-for-pr

hub pull-request


# Celebrate!