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

Introduce Adapter::Base #1138

Merged
merged 1 commit into from
Sep 20, 2015
Merged

Conversation

bf4
Copy link
Member

@bf4 bf4 commented Sep 11, 2015

Why?

  • using a class as a namespace that you also inherit from is complicated and circular at time i.e. buggy (see Remove Adapter autoloads in favor of require #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

TODO

  • Add to changelog
  • document breaking change in Adapter from class -> module and base class from Adapter -> Adapter::Base

@@ -1,30 +1,33 @@
module ActiveModel
class Serializer
class Adapter
module Adapter
Copy link
Member Author

Choose a reason for hiding this comment

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

possible source of error

Copy link
Member Author

Choose a reason for hiding this comment

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

fixed

@bf4 bf4 force-pushed the introduce_adapter_base branch 4 times, most recently from 0c16fe8 to b6e3a96 Compare September 18, 2015 20:07
@bf4 bf4 changed the title WIP: Introduce Adapter::Base Introduce Adapter::Base Sep 18, 2015
class << self # All methods are class functions
def new(*args)
fail ArgumentError, [args, caller[0]].inspect
end
Copy link
Member Author

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

@NullVoxPopuli
Copy link
Contributor

Are you gonna add to changlog and document the breaking change in this PR?

@NullVoxPopuli
Copy link
Contributor

otherwise 👍

@NullVoxPopuli
Copy link
Contributor

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
end

def root
serializer.json_key.to_sym if serializer.json_key
Copy link
Contributor

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?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think just evolution...

@beauby
Copy link
Contributor

beauby commented Sep 20, 2015

LGTM, merging.

beauby added a commit that referenced this pull request Sep 20, 2015
@beauby beauby merged commit ab1e2af into rails-api:master Sep 20, 2015
@bf4 bf4 deleted the introduce_adapter_base branch September 20, 2015 22:05
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.

None yet

3 participants