Skip to content

Instantly share code, notes, and snippets.

@eduardodeoh
Last active September 23, 2015 12:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save eduardodeoh/f44947d74c593c4ca612 to your computer and use it in GitHub Desktop.
Save eduardodeoh/f44947d74c593c4ca612 to your computer and use it in GitHub Desktop.
Rom Mapper - Hash with keys with object to plain hash
class Parents
include Anima.new(:mother_name, :father_name)
end
person_hash = { name: "eduardo", :parents=>#<Parents mother_name="Mary" father_name="Joe"> }
class PersonHashToNewHash < ::ROM::Mapper
relation :person
register_as :person_to_new_hash
unwrap :parents do
attribute :father, from: :father_name
attribute :mother, from: :mother_name
end
end
my_required_result = { name: "eduardo", father: "Joe", mother: "Mary" }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment