Last active
September 23, 2015 12:18
-
-
Save eduardodeoh/f44947d74c593c4ca612 to your computer and use it in GitHub Desktop.
Rom Mapper - Hash with keys with object to plain hash
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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