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:

  1. Let the user work with the HTTParty::Response object directly
  2. Convert to a Hash somehow?
  3. Create an instance of a class that has attributes/fields as the keys in the Response object?
Was it helpful?

Solution

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top