active_model_serializers

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

Ruby

ActiveModel::Serializer implementation and Rails hooks

ActiveModelSerializers::Model.attributes

Easily declare instance attributes with setters and getters for each.

All attributes to initialize an instance must have setters.
However, the hash turned by +attributes+ instance method will ALWAYS
be the value of the initial attributes, regardless of what accessors are defined.
The only way to change the change the attributes after initialization is
to mutate the +attributes+ directly.
Accessor methods do NOT mutate the attributes.  (This is a bug).

Source | Google | Stack overflow

Edit

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

cd active_model_serializers

open lib/active_model_serializers/model.rb

Contribute

# Make a new branch

git checkout -b -your-name--update-docs-ActiveModelSerializers--Model-attributes-for-pr


# Commit to git

git add lib/active_model_serializers/model.rbgit commit -m "better docs for ActiveModelSerializers::Model.attributes"


# Open pull request

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

hub fork

git push <your name> -your-name--update-docs-ActiveModelSerializers--Model-attributes-for-pr

hub pull-request


# Celebrate!