I just started to get a handle on conceptualizing Ruby classes and am feeling like there is a lot of potential here. I have yet to see how to apply them when it comes to creating a restful API though. What is the application of classes in terms of a REST Api?
For further actions, you may consider blocking this person and/or reporting abuse
Top comments (8)
A class is a template for objects, if you were building an API that queried a database of movies you would probably have a classes for things like Movies, Characters, and Actors. You would have tables in your database that coincide with each class you define.
ohhhhhh that makes sense, thank you this adds a lot of clarity, thank you.
(non-tricky questions) (no need to google the answer)
Could you elaborate your current understanding of what a class is?
Would you mind sharing an example you see without REST involved?
What is REST in your view? How do you make sense of it?
Sorry, guess that description can be misleading because of how I am referring to rest Api and what Rest Api is defined as. I mean in terms of a making Api's and or making Api calls. To re-phrase my question, What role does Ruby classes play in handling Api creation and Api requests?
All good :)
In our context, a Ruby class is one of the prerequisites to create an API
The request comes as plain text. But then it gets transformed into an object that is made of a Ruby class. Like a Hash for example.
You mentioned classes and handling requests. So here's what I think this means in practice in Ruby on Rails: ActionDispatch::Http::Request.
The mechanics of it uses Controllers in Rails case. Assuming that's what you're learning. I recommend a read at Rails guides for further clarification.
This is exactly what I was looking for thank you.
Its all coming together now this is so sick! can't wait to try this out. thank you.