I'm working on a project where I do #3 actually. I use HTTParty to convert the data to a hash and then use the hash to create a related set of ActiveRecord classes. It's easier to manipulate the data (do validation for example) in a Ruby class than it is to leave it in the raw hash.
Design decisions when writing an API wrapper with HTTParty in Ruby
Question
I'm writing an API wrapper in Ruby and not sure how to proceed. HTTParty
is very nice and takes care of everything for me, but on HTTParty::get
it returns an HTTParty::Response
object.
I want to know, is it better to:
- Let the user work with the
HTTParty::Response
object directly - Convert to a Hash somehow?
- Create an instance of a class that has attributes/fields as the keys in the Response object?
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow