-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Conversation
## 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 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"When a resource"
👍 Some minor comments. Really cool that you took the time to write that, I think it'll save quite some time to new contributos. |
I want docs to point to for common questions. Maybe I'll make an erd or sequence diagran B mobile phone
|
@rails-api/ams updated with more awesomeness. |
|
||
## What does a 'serializable resource' look like? | ||
|
||
- An `ActiveRecord::Base` object. |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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) |
There was a problem hiding this comment.
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
Updated a bit.. needs some review |
end | ||
``` | ||
|
||
The default serializer for `MyModel` would be `MyModelSerializer` whether MyModel is an |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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...
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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 for
MyModel
would 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.
Made a remark and a few minor changes, but LGTM otherwise. |
Describe AMS architecture in the big picture
👍 |
Closes #1191