Skip to content

Record Accessors#977

Merged
lgebhardt merged 2 commits intoJSONAPI-Resources:masterfrom
lgebhardt:record_accessors
Feb 10, 2017
Merged

Record Accessors#977
lgebhardt merged 2 commits intoJSONAPI-Resources:masterfrom
lgebhardt:record_accessors

Conversation

@lgebhardt
Copy link
Contributor

JR has gradually grown so Resources were very ActiveRecord dependent, making the project difficult to use with no-sql and poro based models. This PR should fix this in a mostly backwards compatible way.

A RecordAccessor class for ActiveRecord was created, named ActiveRecordAccessor. This provides support for ActiveRecord along with caching. The goal was to keep backwards compatibility with existing resources. In order to achieve that goal methods which were previously documented as overridable are check to see if they are on the model and called instead of the Accessor method. It is probable/possible that some projects are overriding additional methods and this change will break code.

This change should pave the way for supporting models based on POROs and other database systems like MongoDB.

Breaking changes:

  • caching support for non ActiveResource resources has been disabled. Given the very limited support for non ActiveRecord data I believe this support was rarely used and should be implemented in a proper RecordAccessor.
  • a lot of functionality has been moved from the Resource class to the RecordAccessors, which may break some resource customizations based on overriding methods.

Removing AR specific code from Resource and moving to new RecordAccessor class.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants