Skip to content

Commit

Permalink
Touch ups
Browse files Browse the repository at this point in the history
  • Loading branch information
bf4 committed Dec 13, 2015
1 parent 6098887 commit edd6e21
Show file tree
Hide file tree
Showing 14 changed files with 42 additions and 46 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ architecture. We'd love your help. [Learn how you can help here.](https://github

## Installation

Note: *ActiveModelSerializers is already included on Rails >= 5*

Add this line to your application's Gemfile:

```
Expand All @@ -61,11 +63,12 @@ And then execute:
$ bundle
```

*ActiveModelSerializers is already included on Rails >= 5*
## Getting Started

See [Getting Started](docs/general/getting_started.md) for the nuts and bolts.

## High-level behavior

See [Getting Started](docs/general/getting_started.md) for the nuts and bolts:

Given a [serializable model](lib/active_model/serializer/lint.rb):

Expand Down
13 changes: 1 addition & 12 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ This is the documentation of ActiveModelSerializers, it's focused on the **0.10.
- [Caching](general/caching.md)
- [Logging](general/logging.md)
- [Instrumentation](general/instrumentation.md)
- [JSON API Schema](jsonapi/schema.md)

## How to

Expand All @@ -29,15 +30,3 @@ This is the documentation of ActiveModelSerializers, it's focused on the **0.10.
| Grape | 0.10.x + | [#1258](https://github.com/rails-api/active_model_serializers/issues/1258) |
| Grape | 0.9.x | https://github.com/jrhe/grape-active_model_serializers/ |
| Sinatra | 0.9.x | https://github.com/SauloSilva/sinatra-active-model-serializers/

## Getting Help

If you find a bug, please report an [Issue](https://github.com/rails-api/active_model_serializers/issues/new).

If you have a question, please [post to Stack Overflow](http://stackoverflow.com/questions/tagged/active-model-serializers).

Thanks!

## Contributing

See [CONTRIBUTING.md](https://github.com/rails-api/active_model_serializers/blob/master/CONTRIBUTING.md)
27 changes: 4 additions & 23 deletions docs/general/adapters.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[Back to Guides](../README.md)

# Adapters

ActiveModelSerializers offers the ability to configure which adapter
Expand Down Expand Up @@ -28,7 +30,7 @@ The local adapter option is in the format `adapter: adapter`, where `adapter` is
any of the same values as set globally.

The configured adapter can be set as a symbol, class, or class name, as described in
[Advanced adapter configuration](adapters.md#Advanced adapter configuration).
[Advanced adapter configuration](adapters.md#advanced-adapter-configuration).

The `Attributes` adapter does not include a root key. It is just the serialized attributes.

Expand All @@ -51,7 +53,7 @@ Doesn't follow any specific convention.

### JSON API

This adapter follows **version 1.0** of the format specified in
This adapter follows **version 1.0** of the [format specified](../jsonapi/schema.md) in
[jsonapi.org/format](http://jsonapi.org/format).

#### Included
Expand Down Expand Up @@ -107,27 +109,6 @@ The user could pass in `include=**`.

We recommend filtering any user-supplied includes appropriately.

## Choosing an adapter

If you want to use a specify a default adapter, such as JsonApi, you can change this in an initializer:

```ruby
ActiveModelSerializers.config.adapter = ActiveModel::Serializer::Adapter::JsonApi
```

or

```ruby
ActiveModelSerializers.config.adapter = :json_api
```

If you want to have a root key for each resource in your responses, you should use the Json or
JsonApi adapters instead of the default Attributes:

```ruby
ActiveModelSerializers.config.adapter = :json
```

## Advanced adapter configuration

### Registering an adapter
Expand Down
2 changes: 2 additions & 0 deletions docs/general/caching.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[Back to Guides](../README.md)

# Caching

To cache a serializer, call ```cache``` and pass its options.
Expand Down
2 changes: 2 additions & 0 deletions docs/general/configuration_options.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[Back to Guides](../README.md)

# Configuration Options

The following configuration options can be set on `ActiveModelSerializers.config`,
Expand Down
2 changes: 2 additions & 0 deletions docs/general/getting_started.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[Back to Guides](../README.md)

# Getting Started

## Creating a Serializer
Expand Down
3 changes: 3 additions & 0 deletions docs/general/instrumentation.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[Back to Guides](../README.md)

# Instrumentation

ActiveModelSerializers uses the
Expand Down Expand Up @@ -30,6 +32,7 @@ ActiveSupport::Notifications.subscribe 'render.active_model_serializers' do |*ar
# event.payload
# whatever
end
```

## [LogSubscriber](http://api.rubyonrails.org/classes/ActiveSupport/LogSubscriber.html)

Expand Down
6 changes: 4 additions & 2 deletions docs/general/logging.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
[Back to Guides](../README.md)

# Logging

If we are using ActiveModel::Serializers on Rails app by default the `Rails.logger` will be used.
If we are using ActiveModelSerializers on a Rails app by default the `Rails.logger` will be used.

On a non Rails enviroment by default the `ActiveSupport::TaggedLogging` will be
used.

If we need to customize the logger we can define this in an initializer:
You may customize the logger we by in an initializer, for example:

```ruby
ActiveModelSerializers.logger = Logger.new(STDOUT)
Expand Down
2 changes: 2 additions & 0 deletions docs/howto/rendering.md → docs/general/rendering.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[Back to Guides](../README.md)

# Rendering

### Implicit Serializer
Expand Down
12 changes: 7 additions & 5 deletions docs/general/serializers.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[Back to Guides](../README.md)

# Serializers

Given a serializer class:
Expand Down Expand Up @@ -27,10 +29,10 @@ Serialization of the resource `title`

| In Serializer | #attributes |
|---------------------------- |-------------|
| `attribute :title` | { title: 'Some Title' } `
| `attribute :title, key: :name` | { name: 'Some Title' } `
| `attribute :title { 'A Different Title'}` | { title: 'A Different Title' } `
| `attribute :title`<br>`def title 'A Different Title' end` | { title: 'A Different Title' }`
| `attribute :title` | `{ title: 'Some Title' } `
| `attribute :title, key: :name` | `{ name: 'Some Title' } `
| `attribute :title { 'A Different Title'}` | `{ title: 'A Different Title' } `
| `attribute :title`<br>`def title 'A Different Title' end` | `{ title: 'A Different Title' }`


### Associations
Expand Down Expand Up @@ -139,7 +141,7 @@ class CommentSerializer < ActiveModel::Serializer
end
```

Generally speaking, you as a user of ActiveModelSerializers will write (or generate) these
Generally speaking, you, as a user of ActiveModelSerializers, will write (or generate) these
serializer classes.

## More Info
Expand Down
2 changes: 2 additions & 0 deletions docs/howto/add_pagination_links.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[Back to Guides](../README.md)

# How to add pagination links

### JSON API adapter
Expand Down
6 changes: 4 additions & 2 deletions docs/howto/outside_controller_use.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[Back to Guides](../README.md)

## Using ActiveModelSerializers Outside Of A Controller

### Serializing a resource
Expand All @@ -18,7 +20,7 @@ serializable_resource = ActiveModel::SerializableResource.new(post, options)
model_json = serializable_resource.as_json
```

### Retrieving a Resource's Active Model Serializer
### Looking up the Serializer for a Resource

If you want to retrieve a serializer for a specific resource, you can do the following:

Expand All @@ -39,4 +41,4 @@ You could also retrieve the serializer via:
ActiveModel::SerializableResource.new(post, options).serializer
```

Both approaches will return an instance, if any, of the resource's serializer.
Both approaches will return an instance, if any, of the resource's serializer.
2 changes: 2 additions & 0 deletions docs/integrations/ember-and-json-api.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[Back to Guides](../README.md)

# Integrating with Ember and JSON API

- [Preparation](./ember-and-json-api.md#preparation)
Expand Down
2 changes: 2 additions & 0 deletions docs/jsonapi/schema.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
[Back to Guides](../README.md)

[![JSON API 1.0](https://img.shields.io/badge/JSON%20API-1.0-lightgrey.svg)](http://jsonapi.org/)

## JSON API Requests
Expand Down

0 comments on commit edd6e21

Please sign in to comment.