I wouldn't turn the entire Amazon hash into an OpenStruct
. And since product.name
is nil
you can't do a find on it.
Instead, just loop through the Amazon items, assign them to your product, and then add to the @products
array:
@products = []
hashed_products['ItemSearchResponse']['Items']['Item'].each do |item|
product = OpenStruct.new
product.name = item['ItemAttributes']['Title']
@products << product
end