-
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
Introduce Adapter::Base #1138
Introduce Adapter::Base #1138
Conversation
@@ -1,30 +1,33 @@ | |||
module ActiveModel | |||
class Serializer | |||
class Adapter | |||
module Adapter |
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.
possible source of error
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.
fixed
0c16fe8
to
b6e3a96
Compare
class << self # All methods are class functions | ||
def new(*args) | ||
fail ArgumentError, [args, caller[0]].inspect | ||
end |
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.
Just in case.. but perhaps I could write a better message.. is really meant to be a helpful deprecation fast failure
b6e3a96
to
32a1a16
Compare
Are you gonna add to changlog and document the breaking change in this PR? |
otherwise 👍 |
ping @bf4 |
Breaking change: - Adapters now inherit Adapter::Base - 'Adapter' is now a module, no longer a class Why? - using a class as a namespace that you also inherit from is complicated and circular at time i.e. buggy (see rails-api#1177) - The class methods on Adapter aren't necessarily related to the instance methods, they're more Adapter functions - named `Base` because it's a Rails-ism - It helps to isolate and highlight what the Adapter interface actually is
32a1a16
to
19de5f7
Compare
end | ||
|
||
def root | ||
serializer.json_key.to_sym if serializer.json_key |
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.
What's the rationale behind calling it root
in the adapter and json_key
in the serializer?
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.
I think just evolution...
LGTM, merging. |
Why?
Base
because it's a Rails-ismTODO