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

JSON-API support for :extends/:decorator with has_one #11

Closed
myabc opened this issue Dec 10, 2016 · 0 comments
Closed

JSON-API support for :extends/:decorator with has_one #11

myabc opened this issue Dec 10, 2016 · 0 comments

Comments

@myabc
Copy link
Collaborator

myabc commented Dec 10, 2016

From @caseymct on January 8, 2016 4:16

as per glitter chat:

I have an Event model that has_one host, a User. the User model has it's own (quite large) decorator. It would be great to have

has_one :host, class: User, decorator: UserDecorator

I'd like to avoid doing

has_one :host, class: User, populator: ::Representable::FindOrInstantiate do
  # many properties
end

and duplicating this in every decorator that has a user.

Copied from original issue: trailblazer/roar#182

myabc added a commit that referenced this issue Jan 7, 2017
This refactoring attempts to make better use of existing Represntable
idioms, such as `representation_wrap`.

API changes:
* `id` property is automatically defined for a resource.
* resource attributes should be specified in `attributes` block.
* `has_one` and `has_many` now support `decorates:` option (in other
  words, no longer confined to Inline Representers)

Closes #11

Signed-off-by: Alex Coles <alex@alexbcoles.com>
myabc added a commit that referenced this issue Jan 7, 2017
This refactoring attempts to make better use of existing Represntable
idioms, such as `representation_wrap`.

API changes:
* `id` property is automatically defined for a resource.
* resource attributes should be specified in `attributes` block.
* `has_one` and `has_many` now support `decorates:` option (in other
  words, no longer confined to Inline Representers)

Closes #11

Signed-off-by: Alex Coles <alex@alexbcoles.com>
@myabc myabc closed this as completed in #17 Jan 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant