-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Description
Hey,
I am begging to learn ruby and I am a little "desoriented", I hope you can help me.
I've been trying to map an attribute from class User to an attribute of an attribute of class Person, but I am unable to find out how to do it.
At the end, I want the Person json/hash to be kind of specific...
class Person
include Virtus
attribute :first_name, String
# attribute :phone_numbers, Array ???
end
class User < ActiveRecord::Base
# name
# phone_number
end
mapper = SimpleAttributeMapper::Mapper.new({
:name => :first_name,
# ???
})
user = User.new(:name => "Astolfo", :phone_number => "12345678")
person = mapper.map(user, Person)
person.to_json # => {:first_name=>"Astolfo", :phone_numbers => [ { :number => "12345678" } ]Thanks in advance!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels