Skip to content
This repository was archived by the owner on Jan 30, 2019. It is now read-only.
This repository was archived by the owner on Jan 30, 2019. It is now read-only.

Render hashes? #42

Open
Open
@alfuken

Description

@alfuken

I have a list of prices for a product

prices = [
  #<Price currency="usd", value="130">,
  #<Price currency="eur", value="100">,
  #<Price currency="gbp", value="70">,
]

and want to render it like this:

"product": {
  "title": "foo",
  "prices": {
    "usd": 130,
    "eur": 100,
    "gbp": 70
  }
}

Problem is, array of prices is not always the same - it may or may not have other currencies, there can be 10, there can be 1, there can be none at all.
I've spent whole day trying to figure out, how do I handle anything other than plain array, and couldn't find a clue.
So my question is: how do I do this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions