Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Describe AMS architecture in the big picture #1253

Merged
merged 2 commits into from
Oct 22, 2015
Merged

Describe AMS architecture in the big picture #1253

merged 2 commits into from
Oct 22, 2015

Conversation

bf4
Copy link
Member

@bf4 bf4 commented Oct 7, 2015

Closes #1191

## Primitive handling

ActiveModelSerializers doesn't handle primitives, such as a String or Array, passed to `render json:`.
When an resource being serialized has an assocation that is a primitive, or is a primitive
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"When a resource"

@beauby
Copy link
Contributor

beauby commented Oct 8, 2015

👍 Some minor comments. Really cool that you took the time to write that, I think it'll save quite some time to new contributos.

@bf4
Copy link
Member Author

bf4 commented Oct 9, 2015

I want docs to point to for common questions. Maybe I'll make an erd or sequence diagran

B mobile phone

On Oct 8, 2015, at 5:33 PM, Lucas Hosseini notifications@github.com wrote:

Some minor comments. Really cool that you took the time to write that, I think it'll save quite some time to new contributos.


Reply to this email directly or view it on GitHub.

@bf4
Copy link
Member Author

bf4 commented Oct 9, 2015

@rails-api/ams updated with more awesomeness.


## What does a 'serializable resource' look like?

- An `ActiveRecord::Base` object.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cribbed from my comment in #1241 (diff)

associations should represent the serialization of the resource. It requires an adapter to
transform its attributes into a JSON document; it cannot be serialized itself.

The `ActiveModel::ArraySerializer` represent a collection of resources as serializers
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ref #1251 to rename it to CollectionSerializer

@@ -0,0 +1,113 @@
# ARCHITECTURE

An `ActiveModel::Serializer` is essentially a [Decorator](http://c2.com/cgi/wiki?DecoratorPattern)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More of a presenter I'm thinking now

@bf4
Copy link
Member Author

bf4 commented Oct 21, 2015

Updated a bit.. needs some review

end
```

The default serializer for `MyModel` would be `MyModelSerializer` whether MyModel is an
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we talk briefly about serializer lookup here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you're welcome to write a follow-up :) work-in-progress right?

Also, I'm still not sure to what extent this is high-level vs. low-level...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

maybe a link to another doc which goes in to deail about lookup, namespacing, and versioning scenarios?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Link or next pr 'cause i want to get sometging inmaster

B mobile phone

On Oct 22, 2015, at 8:21 AM, L. Preston Sego III notifications@github.com wrote:

In docs/ARCHITECTURE.md:

+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).
+
+ActiveModelSerializers::Model may be used either as a template, or in production code.
+
+```ruby
+class MyModel < ActiveModelSerializers::Model

  • attr_accessor :id, :name, :level
    +end
    +```

+The default serializer forMyModelwould beMyModelSerializer whether MyModel is an
maybe a link to another doc which goes in to deail about lookup, namespacing, and versioning scenarios?


Reply to this email directly or view it on GitHub.

@beauby
Copy link
Contributor

beauby commented Oct 22, 2015

Made a remark and a few minor changes, but LGTM otherwise.

bf4 added a commit that referenced this pull request Oct 22, 2015
Describe AMS architecture in the big picture
@bf4 bf4 merged commit 9b0c865 into master Oct 22, 2015
@bf4 bf4 deleted the architecture branch October 22, 2015 15:37
@NullVoxPopuli
Copy link
Contributor

👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants