Next-gen ruby libs! » github.com/dry-rb » website: https://dry-rb.org » forum: https://discourse.dry-rb.org
is there a good ruby gem for transforming hash structures in a declarive, functional way. eg, consider this code I just wrote:
feed = ParsedFeedjiraFeed.new(url)
Item.new(
title: feed.title,
author: feed.itunes_author,
article_link: feed.url,
mp3_link: feed.enclosure_url
)
This is no big deal, because I’m just changing names in a flat hash, but you can imagine more complex cases where you are changing the actual structure (input is deeply nested, output is flat or nested in a different way, etc). what you want to do in these cases is simply specify a mapping from the input name paths to the output name paths using a dot syntax or similar. most functional langs make this kind of thing easy to do but i’d like to do the same in ruby.