Skip to content

Commit

Permalink
Wording and typos.
Browse files Browse the repository at this point in the history
  • Loading branch information
beauby committed Oct 22, 2015
1 parent a5defcb commit d3a8006
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions docs/ARCHITECTURE.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

An **`ActiveModel::Serializer`** wraps a [serializable resource](https://github.com/rails/rails/blob/4-2-stable/activemodel/lib/active_model/serialization.rb)
and exposes an `attributes` method, among a few others.
It allows you to specify which attributes and associations should represent the serialization of the resource.
It allows you to specify which attributes and associations should be represented in the serializatation of the resource.
It requires an adapter to transform its attributes into a JSON document; it cannot be serialized itself.
It may be useful to think of it as a
[presenter](http://blog.steveklabnik.com/posts/2011-09-09-better-ruby-presenters).
Expand All @@ -12,12 +12,12 @@ and, if there is no serializer, primitives.

The **`ActiveModel::Adapter`** describes the structure of the JSON document generated from a
serializer. For example, the `Attributes` example represents each serializer as its
unmodified attributes. The `JsonApi` adatper represents the serializer as a [JSON
unmodified attributes. The `JsonApi` adapter represents the serializer as a [JSON
API](jsonapi.org/) document.

The **`ActiveModel::SerializableResource`** acts to coordinate the serializer(s) and adapter
to an object that responds to `to_json`, and `as_json`. It is used in the controller to
encapsulate the serialization resource when rendered. Thus, it can be used on its own
encapsulate the serialization resource when rendered. However, it can also be used on its own

This comment has been minimized.

Copy link
@bf4

bf4 Oct 22, 2015

Member

My gut is to disagree with this as However. Could you help me understand how it's contrary?

This comment has been minimized.

Copy link
@beauby

beauby Oct 22, 2015

Author Contributor

In the sense that it is not exclusively used inside a controller.

This comment has been minimized.

Copy link
@bf4

bf4 Oct 22, 2015

Member

Oh, I see it as

AM::SerializableResource ... encapsulates .. thus...

but you see it as

AM::SerializableResource ... in the controller .. however

?

This comment has been minimized.

Copy link
@bf4

bf4 Oct 22, 2015

Member

I see AM::SerializableResource as something the controller uses; not a controller concern.

This comment has been minimized.

Copy link
@beauby

beauby Oct 22, 2015

Author Contributor

Yup, that's how I understood it.

to serialize a resource outside of a controller, as well.

## Primitive handling
Expand All @@ -29,7 +29,7 @@ defined for them; they will be serialized when the resource is converted to JSON
ActiveModelSerializers doesn't handle primitives passed to `render json:` at all.

However, when a primitive value is an attribute or in a collection,
it is is not modified.
it is not modified.

Internally, if no serializer can be found in the controller, the resource is not decorated by
ActiveModelSerializers.
Expand All @@ -50,8 +50,8 @@ reflection_options[:virtual_value] = association_value.try(:as_json) || associat
High-level overview:

- For a collection
- the collection serializer is the `:serializer` option and
- `:each_serializer` is used as the serializer for each resource in the collection.
- `:serializer` specifies the collection serializer and
- `:each_serializer` specifies the serializer for each resource in the collection.
- For a single resource, the `:serializer` option is the resource serializer.
- Options are partitioned in serializer options and adapter options. Keys for adapter options are specified by
[`ADAPTER_OPTIONS`](https://github.com/rails-api/active_model_serializers/blob/master/lib/active_model/serializable_resource.rb#L4).
Expand Down Expand Up @@ -92,7 +92,7 @@ Details:

ActiveModelSerializers provides a
`[ActiveModelSerializers::Model](https://github.com/rails-api/active_model_serializers/blob/master/lib/active_model_serializers/model.rb)`,
which is a simple serializable PORO (plain-old Ruby object).
which is a simple serializable PORO (Plain-Old Ruby Object).

ActiveModelSerializers::Model may be used either as a template, or in production code.

Expand Down

0 comments on commit d3a8006

Please sign in to comment.