-
Notifications
You must be signed in to change notification settings - Fork 61
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
What's the strategy to create multiple representations for the same class based on criteria? #116
Comments
I responded on SO. |
Hey, Nick. As you can see this can really become a mess of the representers really fast ( I can organize them in subfolders, but still) - I'm working on the bare bones of the app right now, but I will need to start implementing this fairly soon - so just trying to step ahead of the game. |
Also on the "If I create multiple representers, for the same class, how can I use represents / respond_with pattern vs respond_to / render ?" part of the question - can you put up a small example illustrating this please? - Non of the examples seem to combine both. Thanks. |
Looks like you have a lot of different contexts. Do they all share the same document structure and then just hide certain parts, or does the document structure change reg. different contexts? I am still playing with how to solve this in a beautiful way, since this is one of the major points of Trailblazer (polymorphic handling of different contexts for business logic, representers, forms, and authorization). We'll talk about that in the book, too (feel free to buy it now). 😉 |
@konung Please paste some scenarios here! I'm really interested in handling different contexts easier and more streamlined in Representable. 😬 |
@apotonick Did you find any more beautiful solution ? |
Hello
This is actually a best practices / usage question, as I didn't find any examples of that. Here are two scenarios. I use decorator pattern.
Scenario 1:
Let's say I have a Product class that has multiple attributes & association. By default when somebody makes a request to api.com/products/1 - I want to show everything I've got, but if somebody makes a request to another action like so api.com/products/1/inventory_details - I only want to show limited view that pertains to inventory ( to make it faster for inventory lookups) or if somebody makes a request to api.com/products/1/assembly_details - I want to return a matrix of related sub assemblies along with some relevant product details.
Questions for Scenario 1 :
Scenario 2:
Let's say I have api.com/products/1 that both my internal application can call but that I also want to expose to my clients. However I don't want my clients to see some of the attributes, like inventory details or maybe just one or two attributes. Also depending on the level access of employee, I want to limit their view / representation.
Questions for Scenario 2 :
Any advice would be appriciated. (I'll cross-post this on stackoverflow - http://stackoverflow.com/questions/30127077/strategy-to-create-multiple-representations-for-the-same-class-based-on-criteria)
The text was updated successfully, but these errors were encountered: